Exemple #1
0
        /// <summary>
        /// Returns all service request approval model for the user Id, 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"></param>
        /// <returns></returns>
        public static ServiceRequestApprovalModel GetAllRequests(IServiceRequestController srController, IUserManager userManager, int userId, int currentPage,
                                                                 int pageSize)
        {
            var model = new ServiceRequestApprovalModel {
                Controls = new ServiceRequestApprovalControls()
            };
            var srList = (from s in srController.GetServiceRequestsForRequestorId(userId, userId) where s.State != ServiceRequestState.Cancelled orderby s.Id descending select s).ToList();

            model.ServiceRequests = ConvertToTableModel(userManager, srList, userId);
            Paginate(model, currentPage, pageSize);

            model.Controls.FilterText = "All My Requests";

            return(model);
        }
Exemple #2
0
        /// <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);
        }