public bool CreateHomeStudy(HomeStudyCreate model) { var entity = new HomeStudy() { OwnerId = _userId, Parent1Name = model.Parent1Name, Parent2Name = model.Parent2Name, PhoneNumber = model.PhoneNumber, Email = model.Email, TypeOfHomeStudy = model.TypeOfHomeStudy, Agency = model.Agency }; using (var ctx = new ApplicationDbContext()) { ctx.HomeStudies.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(HomeStudyCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateHomeStudyService(); if (service.CreateHomeStudy(model)) { TempData["SaveResult"] = "Your family was created."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your family could not be created."); return(View(model)); }