Exemple #1
0
        public IActionResult Delete(string id)
        {
            string userId = this.GetUserId();
            var    rs     = _iHolidayService.Delete(id, userId);

            return(Ok(rs));
        }
Exemple #2
0
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            var holiday = _holidayService.GetById(id);

            if (holiday == null)
            {
                return(request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_DELETE_NOT_FOUND));
            }
            if (holiday.Date.Date < DateTime.Now.Date || (holiday.Workingday.HasValue && holiday.Workingday.Value.Date < DateTime.Now.Date))
            {
                return(request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_DELETE_INTHE_PAST));
            }
            _requestService.HandleDeleteHoliday(holiday);
            _holidayService.Delete(id);
            _holidayService.Save();
            return(request.CreateResponse(HttpStatusCode.OK, id));
        }
Exemple #3
0
        public ActionResult Delete(long?id)
        {
            if (id != null)
            {
                var holiday = _holService.GetByID(id.Value);

                _holService.Delete(id.Value);
                TempData["Delete"] = "true";

                var list = _vacreqService.CheckUsersHaveVacation(holiday.Date);
                foreach (var item in list)
                {
                    _mutvacService.SubtractMinutes(item.UserID, SecurityHelper.GetUserId(), item.TotalMinutes);
                }

                return(RedirectToAction("Index", "Holiday"));
            }
            return(RedirectToAction("Index", "Holiday"));
        }
Exemple #4
0
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var     changedEvent = DHXEventsHelper.Bind <HolidayVM>(actionValues);
                holiday h            = new holiday {
                    holidayId = changedEvent.holidayId,
                    startDate = changedEvent.startDate, endDate = changedEvent.endDate, name = changedEvent.name
                };
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    hs.Add(h);
                    hs.Commit();
                    break;

                case DataActionTypes.Delete:
                    hs.Delete(holiday => holiday.holidayId == changedEvent.holidayId);
                    hs.Commit();
                    break;

                case DataActionTypes.Update:
                    hs.Update(h);
                    hs.Commit();
                    break;

                default:
                    break;
                }
                action.TargetId = changedEvent.holidayId;
            }
            catch (Exception a)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
 // DELETE: api/Holidays/5
 public void Delete(int id)
 {
     _holidayService.Delete(id);
 }