Пример #1
0
        public bool CreateCombat(CombatCreate model)
        {
            var entity =
                new Combat()
            {
                OwnerID = _userID,
                Name    = model.Name
            };

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

            var svc = CreateCombatService();

            if (svc.CreateCombat(model))
            {
                TempData["SaveResult"] = "Combat Successfully Created";
                return(RedirectToAction("Index"));
            }

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