Example #1
0
        public bool CreateCondition(ConditionCreate model)
        {
            var entity =
                new Condition
            {
                ConditionName = model.ConditionName,
                ConditionID   = model.ConditionID
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Conditions.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(ConditionCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateConditionService();

            if (service.CreateCondition(model))
            {
                TempData["SaveResult"] = "Condition Created Successfully";
                return(RedirectToAction("Index"));
            }

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