public IActionResult addwedding(weddingrecords newwed) { if (ModelState.IsValid) { int userid = (int)HttpContext.Session.GetInt32("uid"); newwed.UserId = userid; if (newwed.WeddingDate > DateTime.Now) { // newwed.CreatedAt = DateTime.Now; // newwed.UpdatedAt = DateTime.Now; _context.Add(newwed); _context.SaveChanges(); return(RedirectToAction("Dashboard")); } else { ViewBag.errors = "Date should be future dated"; ViewBag.status = "wedaddfaildate"; return(View("addwedding")); } } else { ViewBag.errors = ModelState.Values; ViewBag.status = "wedaddfail"; return(View("addwedding")); } }
public IActionResult deletewed(int weddingid) { weddingrecords weddingrecord = _context.weddings.SingleOrDefault(w => w.WeddingId == weddingid); _context.weddings.Remove(weddingrecord); _context.SaveChanges(); return(RedirectToAction("Dashboard")); }
public IActionResult show(int weddingid) { int userid = (int)HttpContext.Session.GetInt32("uid"); weddingrecords weddingrecord = _context.weddings.SingleOrDefault(w => w.WeddingId == weddingid); List <Invitationsinfo> invitationrecords = _context.invitations.Where(w => w.WeddingId == weddingid) .Include(p => p.Userrecord) .ToList(); ViewBag.invitationrecords = invitationrecords; ViewBag.weddingrecord = weddingrecord; return(View("show")); }