Esempio n. 1
0
        public ActionResult Index()
        {
            var model = new PizzaTypeViewModel();

            model.PizzaTypesList = GetPizzaTypes();

            return(View(model));
        }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
 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();
     }
 }