public ActionResult ExternalShiftRequestIndex() { ExternalShiftRequestListsDTO esr = null; esr = GetExternalshiftRequestList(); return(PartialView(esr)); }
private ExternalShiftRequestListsDTO GetExternalshiftRequestList() { ExternalShiftRequestListsDTO er = new ExternalShiftRequestListsDTO(); 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)) { var response = httpClient.GetAsync("api/ManagerShiftActionAPI/GetExternalShiftRequests").Result; er = JsonConvert.DeserializeObject <ExternalShiftRequestListsDTO>(response.Content.ReadAsStringAsync().Result); // er = Task.Factory.StartNew(() => JsonConvert.DeserializeObject<ExternalShiftRequestListsDTO>(response.Result)).Result; } } return(er); }
public ExternalShiftRequestListsDTO GetExternalShiftRequests() { var email = HttpContext.Current.User.Identity.Name; var retVal = new ExternalShiftRequestListsDTO(); //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 ExternalShiftRequestList = summaryController.ExternalShiftRequestList().Select(sr => new ExternalShiftRequestDTO { Id = sr.Id, ExternalShiftBroadCastID = sr.ExternalShiftBroadcast.Id, UserName = sr.CreatedBy.FirstName + " " + sr.CreatedBy.LastName, ProfileImageData = sr.CreatedBy.UserPreferences.ImageData, Message = sr.ExternalShiftMessage, //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.StartTime, Type = (ExternalShiftRequestTypeDTO)sr.Type, Reason = sr.Reason, Status = (RequestStatusDTO)sr.Status, CreatedDate = (DateTime)sr.CreatedDate }); retVal.ExternalShiftRequests = ExternalShiftRequestList; } return(retVal); }
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)); }