Beispiel #1
0
        public async Task <PagedResultDto <EstimateListDto> > GetAll(EstimateInput input)
        {
            if (!input.Firstname.IsNullOrEmpty())
            {
                input.Firstname = Regex.Replace(input.Firstname.Trim(), @"\s+", " ");
            }

            if (!input.LastName.IsNullOrEmpty())
            {
                input.LastName = Regex.Replace(input.LastName.Trim(), @"\s+", " ");
            }
            var tess      = _estimateRepository.GetAll().Include(x => x.State).ToList();
            var estimates = _estimateRepository.GetAll().Include(x => x.State)
                            .Select(x => new EstimateListDto
            {
                Id          = x.Id,
                LastName    = x.LastName,
                Firstname   = x.Firstname,
                Address     = (x.AddressLine1 == null ? "" : x.AddressLine1 + "-") + (x.AddressLine2 == null ? "" : x.AddressLine2 + "-") + (x.City == null ? "" : x.City + "-") + (x.State.StateName == null ? "" : x.State.StateName),
                Mobile      = x.Mobile,
                TotalAmount = x.TotalAmount
            }).WhereIf(input.Firstname != null, x => x.Firstname.ToUpper().Contains(input.Firstname.ToUpper()))
                            .WhereIf(input.LastName != null, x => x.LastName.ToUpper().Contains(input.LastName.ToUpper()))
                            .ToList();
            var pageOfResults = estimates
                                .Skip(input.SkipCount)
                                .Take(input.MaxResultCount)
                                .ToList();

            return(new PagedResultDto <EstimateListDto>(estimates.Count, pageOfResults));
        }
Beispiel #2
0
        public async Task <FileDto> GetEstimateToExcel(EstimateInput input)
        {
            if (!input.Firstname.IsNullOrEmpty())
            {
                input.Firstname = Regex.Replace(input.Firstname.Trim(), @"\s+", " ");
            }

            if (!input.LastName.IsNullOrEmpty())
            {
                input.Firstname = Regex.Replace(input.LastName.Trim(), @"\s+", " ");
            }

            var estimates = _estimateRepository.GetAll().Include(x => x.State)
                            .Select(x => new EstimateListForExcelDto
            {
                Id            = x.Id,
                LastName      = x.LastName,
                Firstname     = x.Firstname,
                Mobile        = x.Mobile,
                Rate          = x.Rate,
                WorkHours     = x.WorkHours,
                ImportantNote = x.ImportantNote,
                Color         = x.Color,
                NoOfShingles  = x.NoOfShingles,
                ZipCode       = x.ZipCode,
                State         = x.State.StateName,
                AddressLine1  = x.AddressLine1,
                AddressLine2  = x.AddressLine2,
                City          = x.City,
                Email         = x.Email,
                Height        = x.Height,
                Length        = x.Length,
                With          = x.With,
                TotalAmount   = x.TotalAmount
            }).WhereIf(input.Firstname != null, x => x.Firstname.ToUpper().Contains(input.Firstname.ToUpper()))
                            .WhereIf(input.LastName != null, x => x.LastName.ToUpper().Contains(input.LastName.ToUpper()))
                            .ToList();

            return(_estimateExcelExporter.ExportToFile(estimates));
        }