コード例 #1
0
        public ActionResult Create(string shiftId)
        {
            try
            {
                var shift = shiftServices.GetShiftById(shiftId);

                var requestDayOffVM = new AddDayOffRequestVM
                {
                    ShiftId      = shiftId,
                    DateOfShift  = shift.StartTime.Date,
                    ShiftStartAt = shift.StartTime.ToShortTimeString(),
                    ShiftEndAt   = shift.EndTime.ToShortTimeString()
                };

                return(PartialView("_Create_Day_Off_Request", requestDayOffVM));
            }
            catch (Exception ex)
            {
                var userInfo = CookieHelpers.GetUserInfo();
                return(Redirect(string.Format("/Shift/EmployeeView?empId={0}", userInfo.EmployeeId)));
            }
        }
コード例 #2
0
        public ActionResult Create(AddDayOffRequestVM request)
        {
            try
            {
                var userInfo      = CookieHelpers.GetUserInfo();
                var dayOffRequest = new DayOffRequest
                {
                    RequestedShiftId  = request.ShiftId,
                    RequestEmployeeId = userInfo.EmployeeId,
                    RequestedAt       = DateTime.Now,
                    Reason            = request.Reason,
                    Status            = EnumHelpers.GetDescription(DayOffRequestStatus.PENDING)
                };

                var isAdded = dayOffRequestServices.CreateDayOff(dayOffRequest);

                return(Json(new BaseViewModel <bool>(true, string.Empty, isAdded), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new BaseViewModel <bool>(true, ex.Message, false), JsonRequestBehavior.AllowGet));
            }
        }