Example #1
0
        public ActionResult Delete(CalendarCellEventVm calendarEvent)
        {
            try
            {
                _service.Delete(calendarEvent);
            }
            catch (WarningException exception)
            {
                ModelState.AddModelError("", exception.Message);
            }

            return Json(new {});
        }
Example #2
0
        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});
        }
Example #3
0
        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);
                }
            }
        }
Example #4
0
        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;
        }