Пример #1
0
        //
        // GET: /Manager/RequestIndex
        // [Authorize(Roles = Constants.RoleBusinessLocationManager + "," + Constants.RoleBusinessAdmin)]
        public ActionResult ShiftRequestIndex()
        {
            ShiftChangeRequestListsDTO er = null;

            er = GetShiftChangeRequestList();

            return(PartialView(er));
        }
        public ShiftChangeRequestListsDTO GetShiftChangeRequests()
        {
            var email  = HttpContext.Current.User.Identity.Name;
            var retVal = new ShiftChangeRequestListsDTO();

            //Get list of all pending requests for any businesses that the user is a manager of

            //First get list of businesses which user is a manager of
            var mgrBusIdList = from emp in db.Employees
                               where emp.UserProfile.Email == email && emp.IsAdmin == true
                               select emp.BusinessLocation.Id;

            DateTime datetimeNow = WebUI.Common.Common.DateTimeNowLocal();

            using (SummaryAPIController summaryController = new SummaryAPIController())
            {
                //Get list of shift change Requests linked to busineses which user is a manager of
                var shiftRequestList = summaryController.ShiftChangeRequestList(mgrBusIdList.ToList()).Select(sr => new ShiftChangeRequestDTO
                {
                    Id                   = sr.Id,
                    ShiftId              = sr.Shift.Id,
                    EmployeeName         = (sr.Type == ShiftRequestType.TakeOpenShift) ? sr.CreatedBy.FirstName + " " + sr.CreatedBy.LastName : sr.Shift.Employee.FirstName + " " + sr.Shift.Employee.LastName,
                    BusinessLocationName = sr.Shift.InternalLocation.BusinessLocation.Name,
                    BusinessName         = sr.Shift.InternalLocation.BusinessLocation.Business.Name,
                    BusinessLocationId   = sr.Shift.InternalLocation.BusinessLocation.Id,
                    StartDateTime        = sr.Shift.StartTime,
                    FinishDateTime       = sr.Shift.FinishTime,
                    Type                 = (ShiftRequestTypeDTO)sr.Type,
                    Reason               = sr.Reason,
                    Status               = (RequestStatusDTO)sr.Status,
                    CreatedDate          = sr.CreatedDate
                });

                var recurringShiftRequestList = summaryController.RecurringShiftChangeRequestList(mgrBusIdList.ToList()).Select(sr => new RecurringShiftChangeRequestDTO
                {
                    Id                   = sr.Id,
                    ShiftId              = sr.ShiftTemplate.Id,
                    EmployeeName         = sr.ShiftTemplate.Employee.FirstName + " " + sr.ShiftTemplate.Employee.LastName,
                    BusinessLocationName = sr.ShiftTemplate.InternalLocation.BusinessLocation.Name,
                    BusinessName         = sr.ShiftTemplate.InternalLocation.BusinessLocation.Business.Name,
                    OccurenceDate        = sr.OccurenceDate,
                    StartTime            = sr.ShiftTemplate.StartTime,
                    FinishTime           = sr.ShiftTemplate.FinishTime,
                    Type                 = (ShiftRequestTypeDTO)sr.Type,
                    Reason               = sr.Reason,
                    Status               = (RequestStatusDTO)sr.Status,
                    CreatedDate          = sr.CreatedDate
                });

                retVal.ShiftChangeRequests          = shiftRequestList;
                retVal.RecurringShiftChangeRequests = recurringShiftRequestList;
            }
            return(retVal);
        }
Пример #3
0
        private ShiftChangeRequestListsDTO GetShiftChangeRequestList()
        {
            ShiftChangeRequestListsDTO er = new ShiftChangeRequestListsDTO();

            if (ClaimsHelper.IsInRole(System.Web.HttpContext.Current, Constants.RoleBusinessLocationManager))
            {
                //Get a summary of the employes currently linked to the Employee
                using (HttpClientWrapper httpClient = new HttpClientWrapper(Session))
                {
                    Task <String> response = httpClient.GetStringAsync("api/ManagerShiftActionAPI/GetShiftChangeRequests");
                    er = Task.Factory.StartNew(() => JsonConvert.DeserializeObject <ShiftChangeRequestListsDTO>(response.Result)).Result;
                }
            }
            return(er);
        }
Пример #4
0
        public JsonResult GetAllRequests()
        {
            IEnumerable <EmployerRequestDTO> er  = GetEmployerRequestList();
            ShiftChangeRequestListsDTO       scr = GetShiftChangeRequestList();
            ExternalShiftRequestListsDTO     esr = GetExternalshiftRequestList();
            IEnumerable <EmployeeRequestDTO> employeeRequests = GetEmployeeRequestList();
            //IEnumerable<ExternalBroadcastDTO> EmployeeExternalRerquest = GetEmployeeExternalshifts();

            List <RequestDTO> requests = new List <RequestDTO>();

            requests.AddRange(er.Select(req => new RequestDTO
            {
                Id                   = req.Id,
                RequestType          = RequestTypeDTO.Employer,
                RequesterName        = req.Requester_Name,
                BusinessName         = req.Business_Name,
                BusinessLocationName = req.Location_Name,
                CreatedDate          = req.CreatedDate
            }));

            if (scr.ShiftChangeRequests != null)
            {
                //Shift Cancel requests.
                requests.AddRange(scr.ShiftChangeRequests.Where(req => req.Type == ShiftRequestTypeDTO.Cancel).Select(req => new RequestDTO
                {
                    Id                   = req.Id,
                    ShiftId              = req.ShiftId,
                    RequestType          = RequestTypeDTO.ShiftCancel,
                    RequesterName        = req.EmployeeName,
                    BusinessName         = req.BusinessName,
                    BusinessLocationName = req.BusinessLocationName,
                    BusinessLocationId   = req.BusinessLocationId,
                    StartDateTime        = req.StartDateTime,
                    FinishDateTime       = req.FinishDateTime,
                    CreatedDate          = req.CreatedDate,
                    Reason               = req.Reason
                }));

                //Take open shift requests.
                requests.AddRange(scr.ShiftChangeRequests.Where(req => req.Type == ShiftRequestTypeDTO.TakeOpenShift).Select(req => new RequestDTO
                {
                    Id                   = req.Id,
                    ShiftId              = req.ShiftId,
                    RequestType          = RequestTypeDTO.TakeOpenShift,
                    RequesterName        = req.EmployeeName,
                    BusinessName         = req.BusinessName,
                    BusinessLocationName = req.BusinessLocationName,
                    StartDateTime        = req.StartDateTime,
                    FinishDateTime       = req.FinishDateTime,
                    CreatedDate          = req.CreatedDate
                }));
            }


            if (esr.ExternalShiftRequests != null)
            {
                //ExternalShift Cancel requests.
                requests.AddRange(esr.ExternalShiftRequests.Where(req => req.Type == ExternalShiftRequestTypeDTO.Cancel).Select(req => new RequestDTO
                {
                    Id = req.Id,
                    ExternalShiftBroadCastID = req.ExternalShiftBroadCastID,
                    RequestType   = RequestTypeDTO.TakeExternalShiftBroadCast,
                    RequesterName = req.UserName,
                    //BusinessName = req.BusinessName,
                    //BusinessLocationName = req.BusinessLocationName,
                    //BusinessLocationId = req.BusinessLocationId,
                    //StartDateTime = req.StartDateTime,
                    //FinishDateTime = req.FinishDateTime,
                    CreatedDate = req.CreatedDate
                }));

                //Take Externalshift requests.
                requests.AddRange(esr.ExternalShiftRequests.Where(req => req.Type == ExternalShiftRequestTypeDTO.TakeExternalShift).Select(req => new RequestDTO
                {
                    Id = req.Id,
                    ExternalShiftBroadCastID = req.ExternalShiftBroadCastID,
                    RequestType   = RequestTypeDTO.TakeExternalShiftBroadCast,
                    RequesterName = req.UserName,
                    //BusinessName = req.BusinessName,
                    //BusinessLocationName = req.BusinessLocationName,
                    //BusinessLocationId = req.BusinessLocationId,
                    //StartDateTime = req.StartDateTime,
                    //FinishDateTime = req.FinishDateTime,
                    CreatedDate = req.CreatedDate
                }));
            }

            if (scr.RecurringShiftChangeRequests != null)
            {
                //Recurring shift cancel requests.
                requests.AddRange(scr.RecurringShiftChangeRequests.Where(req => req.Type == ShiftRequestTypeDTO.Cancel).Select(req => new RequestDTO
                {
                    Id                   = req.Id,
                    RequestType          = RequestTypeDTO.RecurringShiftCancel,
                    RequesterName        = req.EmployeeName,
                    BusinessName         = req.BusinessName,
                    BusinessLocationName = req.BusinessLocationName,
                    StartDateTime        = DateTime.Parse(req.OccurenceDate.ToShortDateString() + ' ' + req.StartTime.ToString()),
                    FinishDateTime       = DateTime.Parse(req.OccurenceDate.ToShortDateString() + ' ' + req.FinishTime.ToString()),
                    CreatedDate          = req.CreatedDate
                }));
            }
            requests.AddRange(employeeRequests.Select(req => new RequestDTO
            {
                Id                   = req.Id,
                RequestType          = RequestTypeDTO.Employee,
                RequesterName        = null,
                BusinessName         = req.BusinessLocation_Business_Name,
                BusinessLocationName = req.BusinessLocation_Name,
                StartDateTime        = DateTime.MinValue,
                FinishDateTime       = DateTime.MinValue,
                CreatedDate          = req.CreatedDate
            }));


            return(Json(requests));
        }
Пример #5
0
        public JsonResult GetShiftChangeRequests()
        {
            ShiftChangeRequestListsDTO srl = GetShiftChangeRequestList();

            return(Json(srl));
        }