Пример #1
0
        public bool CreateCigarType(CigarTypeCreate model)
        {
            var entity =
                new CigarType
            {
                CigarTypeName = model.CigarTypeName,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.CigarTypes.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #2
0
        public ActionResult Create(CigarTypeCreate model)
        {
            var service = CreateCigarTypeService();

            if (service.CreateCigarType(model))
            {
                TempData["SaveResult"] = "Your Type was created.";
                return(RedirectToAction("Index"));
            }


            ModelState.AddModelError("", "Type could not be created");
            return(View(model));
        }