Friday, 23 September 2016

MVC + Genreic Repository + UOW

enable-migrations -contexttypename schoolcontext
add-migration initialcreate
update-database
install-package PagedList.Mvc
[DatabaseGenerated(DatabaseGeneratedOption.None)] - provided by user - rather generating.
Install-Package SimpleInjector.Integration.Web.Mvc  @Html.ListBox("Categories", (MultiSelectList)ViewBag.Categories , new { @class = "form-control", data_placeholder = "Choose a Category" })

 ViewBag.Categories = new MultiSelectList(db.Categories.ToList(), "Id", "Name");

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.0/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js"></script>

[DataType(DataType.Date), DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode =true)]

 $(function(){
            $(".datepickerClass").datepicker({ dateFormat: 'dd/mm/yy' });
        });

IRepository
public interface IRepository<T> where T : class
    {
        // CRUD
        T Add(T entity);
        IEnumerable<T> All();
        IEnumerable<T> FindBy(Expression<Func<T, bool>> predicate);
        void Edit(T entity);
        T Delete(T entity);

    }

Implement IRepository
 public abstract class Repository<T> : IRepository<T> where T : class
    {
        protected DbContext db;
        public Repository(DbContext _db)
        {
            db = _db;
        }
        public virtual T Add(T entity)
        {
            return db.Set<T>().Add(entity);
        }

        public virtual IEnumerable<T> All()
        {
            return db.Set<T>().AsEnumerable();
        }

        public virtual T Delete(T entity)
        {
            return db.Set<T>().Remove(entity);
        }

        public virtual void Edit(T entity)
        {
            db.Entry(entity).State = EntityState.Modified;
        }

        public virtual IEnumerable<T> FindBy(Expression<Func<T, bool>> predicate)
        {
            return db.Set<T>().Where(predicate).AsEnumerable();
        }

    }

IUnitofWork
public interface IUnitofWork : IDisposable
    {
        int commit();

    }
UnitOfWork
 public sealed class UnitofWork : IUnitofWork
    {
        private  DbContext db;
        public UnitofWork(DbContext _db)
        {
            db = _db;
        }
        public int commit()
        {
            return db.SaveChanges();
        }

        public void Dispose()
        {
            if (db != null)
            {
                db.Dispose();
                db = null;
            }
            GC.SuppressFinalize(db);
        }

    }


Injector DI - App Start
https://simpleinjector.readthedocs.io/en/latest/mvcintegration.html
var container = new Container();
            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

    // Register your types, for instance:
    container.Register<IUserRepository, SqlUserRepository>(Lifestyle.Scoped);

    // This is an extension method from the integration package.
    container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

    // This is an extension method from the integration package as well.
    container.RegisterMvcIntegratedFilterProvider();

    container.Verify();


    DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));



Saturday, 28 November 2015

Scrum Agile Process - Rishi Saini

Agile Principle
Agile Principle helps to deliver small set of functionality with each iterations. Each iteration helps in evolving more productive rules for next iteration by reviewing within business owner and development team.

Advantage
  • Quick response time to urgent issues.
  • Delivery oriented

Scrum
Scrum process is an implementation of agile principles to develop software with efficient teamwork in iterations (called Sprint).

Sprint - is usually of 2-3 weeks cycle to produce deliverable.

Roles 

Product Owner - is representative of business. Product owner creates user stories, prioritize them and add it in Product Backlog. Most important responsibility is make sure development team deliver real value to business with each sprint.

Scrum Master - provides interface between Product owner and development team. Main responsibility is to provide support/help to both of them. Helping product owner in writing user stories and helping development team in overcoming any impediments they are facing. 

Senior in team can play this part-time role. 
Development Team - is appropriate mix of 4-9 team members comprising senior/junior developers & testers team. Ideally team is self manageable would not require managers for daily team operations. 



Work Flow:

Sprint Planning meeting : All 3 roles members join this meeting to create product backlog items. Product owner would communicate most valuable deliverable business is expecting. Scrum master would input the team availability for the sprint. And team would divide requirements into tasks and estimate efforts required. Scrum master would then commit for deliverable according to team availability.

Daily Stand ups Meeting : Motive is daily update on progress of tasks team is working on. Every team members mentions 3 things - 
1. What they worked on yesterday
2. What they will be working on today
3. Any impediments they are facing.
Its time-boxed for 15 mins so all detailed discussion should be avoided and separate meeting can be arrange for it.

Sprint Retrospective meeting : at the end of sprint, team discuss what were good, bad & to improve points in the sprint. These points are discussed and noted by Scrum master and act as guidelines for coming sprints. 

Task Grooming session : Before starting work on tasks they are estimated for the efforts(time) required. Next tasks from product backlog are picked and assigned to team for understanding and investigation. In grooming session, all picked tasks are discussed. The developer investigated the task should provide some more details about the task for other to estimate. 
Scrum master records every individual estimate suggestion and discuss for any anonymity. Once all agrees, the task efforts are assigned. 


In my personal opinion scrum model is very effective in increasing team performance. Also it keeps developer very closely related to overall project progress.








Bevereages

Types of Beverages Fermented - yeast reacts with sugar to convert into ethyl alcohol & CO2. 4-14% Wine (red, white & rose), Cider ...