示例#1
0
        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"));
        }
示例#2
0
        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"));
        }
示例#3
0
        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"));
        }