public ActionResult Published(int?id) { if (id == null) { return(null); } var published = db.EventDetails.Find(id); PublishedViewModel publishedVM = new PublishedViewModel() { EventDetailsId = published.EventDetailsId, EventTitle = published.EventTitle, EventStartTime = published.EventStartTime, EventEndTime = published.EventEndTime, EventMaxTime = published.EventMaxTime, IsActive = published.IsActive }; publishedVM.EventTypeName = db.EventTypess.Where(x => x.EventTypeId == published.EventTypeId).First().EventTypeName; publishedVM.EventVanueName = db.EventVanues.Where(x => x.EventVanueId == published.EventVanueId).First().EventVanueName; return(View(publishedVM)); }
public ActionResult Published(PublishedViewModel publishedViewModel) { var eventDetails = db.EventDetails.Find(publishedViewModel.EventDetailsId); if (eventDetails != null) { if (eventDetails.IsActive == true) { eventDetails.IsActive = false; } else if (eventDetails.IsActive == false) { eventDetails.IsActive = true; } } db.Entry(eventDetails).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }