private HeatChartDetailsVM GetHeatChartDetailsVM()
 {
     return(new HeatChartDetailsVM()
     {
         Specifications = SpecificationList,
         Dimensions = DimensionList,
         MaterialRegisterHeaders = FilterValidMaterialRegisterHeaders(DomainToViewModelCustomMapper.MapMaterialRegisterHeaders(MaterialRegisterHeaders)),
         MaterialRegisterSubSeries = FilterValidMaterialRegisterSubSeries(DomainToViewModelCustomMapper.MapMaterialRegisterSubSeriesList(MaterialRegisterSubSeries))
     });
 }
Beispiel #2
0
        public HttpResponseMessage Search(HttpRequestMessage request, int?page, int?pageSize, string filter = null)
        {
            _requiredRepositories = new List <Type>()
            {
                typeof(MaterialRegisterHeader), typeof(Error)
            };

            int currentPage = page.Value; int currentPageSize = pageSize.Value;

            return(CreateHttpResponse(request, _requiredRepositories, () =>
            {
                HttpResponseMessage response = null;

                List <MaterialRegisterHeader> materialRegisterHeaders = null;

                int totalMaterialRegisters = 0;

                if (!string.IsNullOrEmpty(filter))
                {
                    filter = filter.Trim().ToLower();

                    materialRegisterHeaders = _materialRegisterHeadersRepository.FindBy(mr => mr.CTNumber.ToLower().Contains(filter) && mr.IsDeleted == false)
                                              .OrderByDescending(mr => mr.ModifiedOn)
                                              .Skip(currentPage * currentPageSize)
                                              .Take(currentPageSize)
                                              .ToList();

                    totalMaterialRegisters = _materialRegisterHeadersRepository.FindBy(c => c.IsDeleted == false && c.CTNumber.ToLower().Contains(filter)).Count();
                }
                else
                {
                    materialRegisterHeaders = _materialRegisterHeadersRepository.GetAll().Where(mr => mr.IsDeleted == false)
                                              .OrderByDescending(mr => mr.ModifiedOn)
                                              .Skip(currentPage * currentPageSize)
                                              .Take(currentPageSize)
                                              .ToList();

                    totalMaterialRegisters = _materialRegisterHeadersRepository.FindBy(x => x.IsDeleted == false).Count();
                }

                var materialRegisterHeaderVM = DomainToViewModelCustomMapper.MapMaterialRegisterHeaders(materialRegisterHeaders);

                PaginationSet <MaterialRegisterHeaderVM> pagedSet = new PaginationSet <MaterialRegisterHeaderVM>()
                {
                    Page = currentPage,
                    TotalCount = totalMaterialRegisters,
                    TotalPages = (int)Math.Ceiling((decimal)totalMaterialRegisters / currentPageSize),
                    Items = materialRegisterHeaderVM
                };
                response = request.CreateResponse <PaginationSet <MaterialRegisterHeaderVM> >(HttpStatusCode.OK, pagedSet);
                return response;
            }));
        }
Beispiel #3
0
        public HttpResponseMessage Get(HttpRequestMessage request)
        {
            _requiredRepositories = new List <Type>()
            {
                typeof(MaterialRegisterHeader), typeof(Error)
            };

            return(CreateHttpResponse(request, _requiredRepositories, () =>
            {
                HttpResponseMessage response = null;

                var materialRegisterHeaders = _materialRegisterHeadersRepository.GetAll().Where(x => !x.IsDeleted)
                                              .OrderByDescending(x => x.ModifiedOn).
                                              Take(4).ToList();

                var materialRegisterHeaderVMs = DomainToViewModelCustomMapper.MapMaterialRegisterHeaders(materialRegisterHeaders);

                response = request.CreateResponse(HttpStatusCode.OK, materialRegisterHeaderVMs);

                return response;
            }));
        }