public bool CreateBase(BaseCreate model) { Base militaryBase = new Base() { OwnerID = _userID, BaseName = model.BaseName, BaseCity = model.BaseCity, BaseState = model.BaseState }; using (var ctx = new ApplicationDbContext()) { ctx.Bases.Add(militaryBase); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(BaseCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateRaterService(); if (service.CreateBase(model)) { return(RedirectToAction("Index")); } ModelState.AddModelError("", "Base could not be added"); return(View(model)); }