/// <summary> /// Create the model /// </summary> /// <param name="ps">portfolio service</param> /// <param name="sr"></param> /// <param name="nextState"></param> /// <param name="userId"></param> /// <param name="serviceRequestId"></param> /// <returns></returns> public static ServiceRequestStateChangeModel CreateStateChangeModel(IPortfolioService ps, IServiceRequestController sr, ServiceRequestState nextState, int userId, int serviceRequestId) { var model = new ServiceRequestStateChangeModel { NextState = nextState, ServiceRequestModel = new ServiceRequestModel(), ConfirmNextState = true }; return(AddModelData(model, ps, sr, userId, serviceRequestId)); }
public override void Load(ServiceRequestDocument document) { id = new Id(document.Id); version = new Version(document.Version); _scheduledDate = new ScheduledDate(document.ScheduledDate); _dueDate = new DueDate(document.DueDate); _completionDate = new CompletionDate(document.CompletionDate); _clientId = new Id(document.Client); _serviceId = new Id(document.Service); _assignedTo = new Id(document.AssignedAgent); _state = document.State; }
public ServiceRequestDocument(ScheduledDate scheduledDate, Id clientId, Id serviceId, Id assignedTo, DueDate dueDate, ServiceRequestState state, CompletionDate completed, Version version, Id id) { this.ScheduledDate = scheduledDate ?? new ScheduledDate(DateTime.Now); this.Client = clientId; this.Service = serviceId; this.AssignedAgent = assignedTo ?? Guid.Empty; this.DueDate = dueDate ?? new DueDate(DateTime.Now.AddDays(2)); this.CompletionDate = completed; this.State = state; this.Version = version; this.Id = id; }
private int CreateFakeRequest(ServiceRequestState state) { var fakeRequest = A.Fake <IServiceRequestDto <IServiceRequestOptionDto, IServiceRequestUserInputDto> >(); A.CallTo(() => fakeRequest.State).Returns(state); A.CallTo(() => fakeRequest.CreationDate).Returns(DateTime.UtcNow); A.CallTo(() => fakeRequest.RequestedForDate).Returns(DateTime.UtcNow); A.CallTo(() => fakeRequest.DepartmentId).Returns(DepartmentId); A.CallTo(() => fakeRequest.RequestedByUserId).Returns(UserId); using (var context = new PrometheusContext()) { var request = ManualMapper.MapDtoToServiceRequest(fakeRequest); context.ServiceRequests.Add(request); context.SaveChanges(); return(request.Id); } }
/// <summary> /// Filter by State /// </summary> /// <param name="state"></param> /// <param name="pageId"></param> /// <returns></returns> public ActionResult FilterDepartmentStatus(ServiceRequestState state, int pageId = 0) { ServiceRequestApprovalModel model = new ServiceRequestApprovalModel(); try { model = ServiceRequestApprovalHelper.GetDepartmentRequests(_serviceRequestController, _userManager, UserId, pageId, _pageSize, state); } catch (Exception exception) { TempData["MessageType"] = WebMessageType.Failure; TempData["Message"] = $"Failed to retrieve any service requests, {exception.Message}"; } if (model.Controls != null) { model.Controls.FilterAction = "FilterDepartmentStatus"; } else { model.Controls = new ServiceRequestApprovalControls(); } return(View("Index", model)); }
public ActionResult ChangeState(int id, ServiceRequestState state, string message) { try { switch (state) { case ServiceRequestState.Cancelled: _requestManager.CancelRequest(UserId, id, message); break; case ServiceRequestState.Submitted: _requestManager.SubmitRequest(UserId, id); break; case ServiceRequestState.Approved: _requestManager.ApproveRequest(UserId, id, ApprovalResult.Approved, message); break; case ServiceRequestState.Denied: _requestManager.ApproveRequest(UserId, id, ApprovalResult.Denied, message); break; default: throw new Exception("State not implemented"); //incomplete is one of these } } catch (Exception exception) { TempData["MessageType"] = WebMessageType.Failure; TempData["Message"] = $"Failed to set Service Request to {state}, {exception}"; return(RedirectToAction("Index")); } TempData["MessageType"] = WebMessageType.Success; TempData["Message"] = $"Successfully set Service Request to {state}"; return(RedirectToAction("Index")); }
/// <summary> /// Changes the state of a service request to the state provided if the action is possible. /// </summary> /// <param name="userId">ID of user performing the state change</param> /// <param name="requestId">ID of Service Request to change the state of</param> /// <param name="state">State to change the Service Request to</param> /// <param name="comments">Optional: Comments tied to the state change if applicable</param> /// <returns>Service Request after state change is attempted</returns> public IServiceRequestDto <IServiceRequestOptionDto, IServiceRequestUserInputDto> ChangeRequestState(int userId, int requestId, ServiceRequestState state, string comments = null) { IServiceRequestDto <IServiceRequestOptionDto, IServiceRequestUserInputDto> request = RequestFromId(requestId); switch (state) { case ServiceRequestState.Incomplete: throw new ServiceRequestStateException("Cannot change the state of a Service Request to Incomplete."); case ServiceRequestState.Submitted: return(SubmitRequest(userId, requestId)); case ServiceRequestState.Approved: case ServiceRequestState.Denied: ApprovalResult approval = state == ServiceRequestState.Approved ? ApprovalResult.Approved : ApprovalResult.Denied; return(ApproveRequest(userId, requestId, approval, comments)); case ServiceRequestState.Cancelled: return(CancelRequest(userId, requestId, comments)); case ServiceRequestState.Fulfilled: return(FulfillRequest(userId, requestId, comments)); } return(request); }
/// <summary> /// Returns all service request approval model for the user Id, filtered, and ordered by id /// </summary> /// <param name="srController">service request controller</param> /// <param name="userManager"></param> /// <param name="userId">requesting user</param> /// <param name="currentPage">current page</param> /// <param name="pageSize">page size</param> /// <param name="state">state to filter by</param> /// <returns></returns> public static ServiceRequestApprovalModel GetMyRequests(IServiceRequestController srController, IUserManager userManager, int userId, int currentPage, int pageSize, ServiceRequestState state) { var model = new ServiceRequestApprovalModel { Controls = new ServiceRequestApprovalControls() }; // retrieve filtered data var srList = (from s in srController.GetServiceRequestsForRequestorId(userId, userId) where s.State == state && s.State == state orderby s.Id descending select s).ToList(); model.ServiceRequests = ConvertToTableModel(userManager, srList, userId); Paginate(model, currentPage, pageSize); model.Controls.FilterText = $"Filtered My Requests by {state}"; model.Controls.FilterState = state; //hints to pagination model.Controls.FilterStateRequired = true; return(model); }
/// <summary> /// Get Department Request approvals and filter /// </summary> /// <param name="srController"></param> /// <param name="userManager"></param> /// <param name="userId"></param> /// <param name="currentPage"></param> /// <param name="pageSize"></param> /// <param name="state"></param> /// <returns></returns> public static ServiceRequestApprovalModel GetDepartmentRequests(IServiceRequestController srController, IUserManager userManager, int userId, int currentPage, int pageSize, ServiceRequestState state) { var model = new ServiceRequestApprovalModel { Controls = new ServiceRequestApprovalControls() }; var srList = (from s in srController.GetServiceRequestsForApproverId(userId) where s.State == state orderby s.Id descending select s).ToList(); model.ServiceRequests = ConvertToTableModel(userManager, srList, userId); Paginate(model, currentPage, pageSize); model.Controls.FilterText = $"Filtered Department Requests by {state}"; return(model); }
public void Completed() { this._state = ServiceRequestState.Complete; this._completionDate = new CompletionDate(DateTime.Today); UpdateVersion(); }