public ActionResult Create(UCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateUnethicalService(); if (service.CreateUnethicalOrganization(model)) { TempData["SaveResult"] = "Your organization was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Organization could not be created."); return(View(model)); }
} // // Create Method public bool CreateUnethicalOrganization(UCreate model) { var entity = new UnethicalOrganization() { Id = _userId, UnethicalOrganizationName = model.UnethicalOrganizationName, FastFashion = model.FastFashion, Exploitation = model.Exploitation, Sweatshop = model.Sweatshop, Copyright = model.Copyright, UCountry = model.UCountry, UImprove = model.UImprove }; using (var ctx = new ApplicationDbContext()) { ctx.UnethicalOrganizations.Add(entity); return(ctx.SaveChanges() == 1); } }