public IActionResult AddWedding(AddWedding wedding) { if (ActiveUser == null) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { // add to db Wedding Wedding = new Wedding { CreatedBy = ActiveUser.UserId, WedderOne = wedding.WedderOne, WedderTwo = wedding.WedderTwo, Date = wedding.Date, Address = wedding.Address, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }; _context.weddings.Add(Wedding); _context.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserInfo = ActiveUser; return(View("NewWedding")); }
public IActionResult AddWedding(AddWedding wedding) { System.Console.WriteLine("Add Wedding Works!"); if (ActiveUser == null) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { Wedding Wedding = new Wedding { UserId = ActiveUser.id, WedderOne = wedding.WedderOne, WedderTwo = wedding.WedderTwo, DateOfEvent = wedding.DateOfEvent, Address = wedding.Address, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }; _context.Weddings.Add(Wedding); _context.SaveChanges(); return(RedirectToAction("Dashboard")); } ViewBag.UserInfo = ActiveUser; return(View("NewWedding")); }
public IActionResult CreateWedding(AddWedding TheWedding) { if (ModelState.IsValid) { Wedding Wedding = new Wedding(TheWedding); dbContext.Weddings.Add(Wedding); dbContext.SaveChanges(); return(RedirectToAction("Index")); } else { return(View("WeddingForm")); } }