public ActionResult Create(IntFamilyCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateIntFamilyService(); if (service.CreateIntFamily(model)) { TempData["SaveResult"] = "Your family was created."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your family could not be created."); return(View(model)); }
public bool CreateIntFamily(IntFamilyCreate model) { var entity = new IntFamily() { OwnerId = _userId, Parent1Name = model.Parent1Name, Parent2Name = model.Parent2Name, PhoneNumber = model.PhoneNumber, Email = model.Email, Country = model.Country, USCISExpiration = model.USCISExpiration }; using (var ctx = new ApplicationDbContext()) { ctx.IntFamilies.Add(entity); return(ctx.SaveChanges() == 1); } }