예제 #1
0
        public bool CreatePlatoon(PlatoonCreate model)
        {
            var entity = new Platoon()
            {
                Name     = model.Name,
                Familiar = model.Familiar
            };

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

            if (service.CreatePlatoon(model))
            {
                TempData["Save Result"] = "Record created.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Unable to create record.");
            return(View(model));
        }