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); }
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); }