Ejemplo n.º 1
0
        public OpenCasesDto GetAllCasesWithQuery(List <QueryDto> queries, int pageNumber, int maxRowsPerPage, string sortBy, bool sortDesc)
        {
            try
            {
                using (var context = new CTDSContext())
                {
                    var expression            = QueryBuilder(queries);
                    var filteredCaseTableDtos = (from mcase in context.Case
                                                 join caseStatus in context.CaseStatus on mcase.Id equals caseStatus.CaseId
                                                 join caseInformation in context.CaseInformation on mcase.Id equals caseInformation.CaseId
                                                 join client in context.Client on mcase.Id equals client.CaseId
                                                 join notes in context.Notes on mcase.Id equals notes.CaseId
                                                 select new CaseTableDto
                    {
                        Id = mcase.Id,
                        CaseId = mcase.CaseId,
                        Status = caseStatus.Status,
                        Priority = caseInformation.Priority,
                        CreatedOn = mcase.CreatedOn,
                        Description = caseInformation.Description,
                        Client = client.ClientIdentifier,
                        Notes = notes.NotesByCpa
                    })
                                                .Where(expression)
                                                .ToList();
                    var sortedList = new List <CaseTableDto>();

                    if (sortDesc)
                    {
                        sortedList = filteredCaseTableDtos.OrderByDescending(a => a.GetType().GetProperty(sortBy).GetValue(a, null)).ToList();
                    }
                    else
                    {
                        sortedList = filteredCaseTableDtos.OrderBy(a => a.GetType().GetProperty(sortBy).GetValue(a, null)).ToList();
                    }

                    var          perPageFilteredCaseTableDtos = sortedList.Skip((pageNumber - 1) * maxRowsPerPage).Take(maxRowsPerPage).ToList();
                    OpenCasesDto openCasesDto = new OpenCasesDto()
                    {
                        TotalCount = filteredCaseTableDtos.Count,
                        Cases      = perPageFilteredCaseTableDtos
                    };

                    return(openCasesDto);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 2
0
        public OperationResponse <OpenCasesDto> Post(GetAllCasesWithQuery req)
        {
            OperationResponse <OpenCasesDto> response = new OperationResponse <OpenCasesDto>();

            try
            {
                OpenCasesDto openCaseDto = CaseBusinessLogic.GetAllCasesWithQuery(req.Queries, req.PageNumber, req.maxRowsPerPage);
                response.OnSuccess(openCaseDto, "Success");
                return(response);
            }
            catch (Exception e)
            {
                Log.Error(e.Message + " " + e.StackTrace);
                response.OnException("Req failed at server side");
                return(response);
            }
        }