public bool CreateSponsor(SponsorCreateView model) { var entity = new Sponsor() { BackGroundCheck = model.BackGroundCheck, FirstName = model.FirstName, LastName = model.LastName }; using (var ctx = new ApplicationDbContext()) { ctx.Sponsors.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(SponsorCreateView model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateSponsorService(_userId); if (service.CreateSponsor(model)) { // ViewBag.SaveResult = "Your sponsor was created"; TempData["SaveResult"] = "Your sponsor was created"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Sponsor could not be created"); return(View()); }