public IActionResult Add(AddChurchViewModel addChurchViewModel) { if (ModelState.IsValid) { // Add the new churches to my existing churches Denomination newDenomination = context.Denominations.Single(c => c.ID == addChurchViewModel.DenominationID); Church newChurch = new Church { Name = addChurchViewModel.Name, Denomination = newDenomination }; context.Churches.Add(newChurch); context.SaveChanges(); return(Redirect("/Church")); } return(View(addChurchViewModel)); }
public IActionResult Add(AddDenominationViewModel addDenominationViewModel) { if (ModelState.IsValid) { Denomination newDenomination = new Denomination { Name = addDenominationViewModel.Name }; context.Denominations.Add(newDenomination); context.SaveChanges(); return(Redirect("/Denomination")); } return(View(addDenominationViewModel)); }
public IActionResult Add(RegisterUserViewModel registerUserViewModel) { if (ModelState.IsValid) { User newuser = new User() { UserName = registerUserViewModel.UserName, FirstName = registerUserViewModel.FirstName, LastName = registerUserViewModel.LastName, Email = registerUserViewModel.Email.ToString(), Password = registerUserViewModel.Password }; context.Users.Add(newuser); context.SaveChanges(); return(Redirect("/Login")); } return(View(registerUserViewModel)); }