public ActionResult Delete(CalendarCellEventVm calendarEvent) { try { _service.Delete(calendarEvent); } catch (WarningException exception) { ModelState.AddModelError("", exception.Message); } return Json(new {}); }
public ActionResult Create(CalendarCellEventVm calendarEvent) { int id = 0; try { id = _service.Save(calendarEvent, User.Identity.Name); } catch (WarningException exception) { ModelState.AddModelError("", exception.Message); } return Json(new { id = id}); }
public void Delete(CalendarCellEventVm calendarEvent) { if(calendarEvent.EventType == EventType.Personal) { var toDelete = _unit.PersonalEvent.Get(l => l.Event.Id == calendarEvent.Id); if(toDelete != null) { _unit.PersonalEvent.Delete(toDelete); } } else { var toDelete = _unit.TeamEvent.Get(l => l.Event.Id == calendarEvent.Id); if (toDelete != null) { _unit.TeamEvent.Delete(toDelete); } } }
public int Save(CalendarCellEventVm calendarEvent, string currentUserEmail) { var currentUser = _unit.User.Get(user => user.Email == currentUserEmail); if(currentUser != null) { return _savingService.Save(new CalendarEventVm(calendarEvent.Map()), currentUser.Id); } return 0; }