public ActionResult Delete(PlanningCalendar cEvent) { var calendarEvent = db.PlanningCalendars.FirstOrDefault(s => s.UserId == cEvent.UserId && s.Id == cEvent.Id); if (calendarEvent != null) { db.PlanningCalendars.Remove(calendarEvent); db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit(PlanningCalendar cEvent) { cEvent.UserId = Convert.ToInt32(Session["UserId"]); if (cEvent.Name is null) { cEvent.Name = ""; } if (cEvent.Location is null) { cEvent.Location = ""; } db.Entry(cEvent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(PlanningCalendar cEvent) { cEvent.UserId = Convert.ToInt32(Session["UserId"]); if (cEvent.Name is null) { cEvent.Name = ""; } if (cEvent.Location is null) { cEvent.Location = ""; } db.PlanningCalendars.Add(cEvent); db.SaveChanges(); return(RedirectToAction("Index")); }