public ActionResult Index() { var model = new PizzaTypeViewModel(); model.PizzaTypesList = GetPizzaTypes(); return(View(model)); }
public void Update(PizzaTypeViewModel pizzaTypeVM) { var mapper = AutoMapperConfigs.PizzaTypeVMToPizzaType.CreateMapper(); var pizzaType = mapper.Map <PizzaType>(pizzaTypeVM); using (database = new EFUnitOfWork(connectionName)) { database.PizzaTypes.Update(pizzaType); database.Save(); } }
public void Create(PizzaTypeViewModel pizzaTypeVM) { Mapper.Initialize(cfg => { cfg.CreateMap <PizzaTypeViewModel, PizzaType>(); cfg.CreateMap <SpotViewModel, Spot>().PreserveReferences(); //.PreserveReferences for avoid circuit references => stackoverflowException cfg.CreateMap <PizzaViewModel, Pizza>(); }); using (database = new EFUnitOfWork(connectionName)) { database.PizzaTypes.Create(Mapper.Map <PizzaType>(pizzaTypeVM)); database.Save(); } }