public ActionResult Create(CourtMembersCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateCourtMemberService(); if (service.CreateCourtMembers(model)) { TempData["SaveResult"] = "Court created."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Court not created, verify necessary information was entered"); return(View(model)); }
public bool CreateCourtMembers(CourtMembersCreate model) { var entity = new CourtMembers() { UserId = _userId, JusticeOneChiefJustice = model.JusticeOneChiefJustice, JusticeTwo = model.JusticeTwo, JusticeThree = model.JusticeThree, JusticeFour = model.JusticeFour, JusticeFive = model.JusticeFive, JusticeSix = model.JusticeSix, JusticeSeven = model.JusticeSeven, JusticeEight = model.JusticeEight, JusticeNine = model.JusticeNine, JusticeTen = model.JusticeTen }; using (var ctx = new ApplicationDbContext()) { ctx.CourtMembers.Add(entity); return(ctx.SaveChanges() == 1); } }