public ActionResult Index(ExpenseReportSearchModel.SearchFilters filters) { var model = new ExpenseReportSearchModel(); if (filters != null) { model.Filters = filters; } var submitter = _bus.Send(new EmployeeByUserNameQuery(model.Filters.Submitter)).Result; var approver = _bus.Send(new EmployeeByUserNameQuery(model.Filters.Approver)).Result; var status = !string.IsNullOrWhiteSpace(model.Filters.Status) ? ExpenseReportStatus.FromKey(model.Filters.Status) : null; var specification = new ExpenseReportSpecificationQuery { Approver = approver, Submitter = submitter, Status = status }; ExpenseReport[] orders = _bus.Send(specification).Results; model.Results = orders; return(View(model)); }
public HttpResponseMessage Get(string approverName, string submitterName, string statusCode) { var submitter = _bus.Send(new EmployeeByUserNameQuery(submitterName)).Result; var approver = _bus.Send(new EmployeeByUserNameQuery(approverName)).Result; var status = !string.IsNullOrWhiteSpace(statusCode) ? ExpenseReportStatus.FromKey(statusCode) : null; var specification = new ExpenseReportSpecificationQuery { Approver = approver, Submitter = submitter, Status = status }; ExpenseReport[] orders = _bus.Send(specification).Results; var responseMessage = Request.CreateResponse(HttpStatusCode.OK, orders); return(responseMessage); }
public ActionResult Index(ExpenseReportSearchModel.SearchFilters filters) { var model = new ExpenseReportSearchModel(); if (filters != null) { model.Filters = filters; } var accountManager = _employeeRepository.GetByUserName(model.Filters.Submitter); var practiceOwner = _employeeRepository.GetByUserName(model.Filters.Approver); var status = !string.IsNullOrWhiteSpace(model.Filters.Status) ? ExpenseReportStatus.FromKey(model.Filters.Status) : null; var specification = new SearchSpecification(); specification.MatchSubmitter(accountManager); specification.MatchApprover(practiceOwner); specification.MatchStatus(status); ExpenseReport[] orders = _expenseReportRepository.GetMany(specification); model.Results = orders; return(View(model)); }