public ActionResult ManageEventProposed(OrgEditEventVM model) { var e = db.Events.Find(model.Id); if (model == null) { return(RedirectToAction("EventsProposed", "User")); } if (ModelState.IsValid) { e.name = model.name; e.des = model.des; e.price = model.price; e.availability = model.participants; e.participants = model.participants; e.date = model.date; e.startTime = model.startTime; e.endTime = model.endTime; if (model.Photo != null) { DeletePhoto(e.photoURL); e.photoURL = SavePhoto(model.Photo); } db.SaveChanges(); TempData["info"] = "Event record updated successfully"; return(RedirectToAction("ManageEventProposed", "User", new { id = model.Id })); } return(View(model)); }
// GET: Event/ManageEventProposed public ActionResult ManageEventProposed(int Id) { var e = db.Events.Find(Id); if (e == null) { return(RedirectToAction("EventsProposed", "User")); } var model = new OrgEditEventVM { Id = Id, name = e.name, des = e.des, price = e.price, participants = e.participants, date = e.date, startTime = e.startTime, endTime = e.endTime, availability = e.availability, approvalStat = e.approvalStat, photoURL = e.photoURL, OrgId = e.OrgId, venueId = e.venueId, Organiser = e.Organiser, Venue = e.Venue, Registrations = e.Registrations }; ViewBag.Registrations = db.Registrations.Where(r => r.eventId == Id); ViewBag.ParticipantsCount = db.Registrations.Where(r => r.eventId == Id && r.Payment.status == true).Count(); ViewBag.PendingCount = db.Registrations.Where(r => r.eventId == Id && r.Payment.status == false).Count(); ViewBag.Payments = db.Payments.Where(p => p.Registration.eventId == Id); ViewBag.PaymentsCount = db.Payments.Where(p => p.Registration.eventId == Id).Count(); return(View(model)); }