//[Route("SaveCustomer")] public IActionResult SaveCustomer([FromBody] Customer customer) { try { if (customer == null) { return(BadRequest("Customer is null.")); } CoveragePlan cPlan = null; if (!string.IsNullOrEmpty(customer.CustomerCountry)) { if ((customer.CustomerCountry.ToLower() == "usa") || (customer.CustomerCountry.ToLower() == "can")) { cPlan = _coverageDataRepository.GetAll().Where(cp => (cp.EligibilityCountry == customer.CustomerCountry) && (customer.SaleDate >= cp.EligibilityDateFrom) && (customer.SaleDate <= cp.EligibilityDateTo)).FirstOrDefault(); } else { cPlan = _coverageDataRepository.GetAll().Where(cp => (cp.EligibilityCountry.ToLower() == "other") && (customer.SaleDate >= cp.EligibilityDateFrom) && (customer.SaleDate <= cp.EligibilityDateTo)).FirstOrDefault(); } } if (cPlan != null) { customer.CoveragePlan = cPlan.CoveragePlanName; int customerage = (int)(DateTime.UtcNow - customer.CustomerDateOfBirth).Value.TotalDays / 365; RateChart rc = _rateChartDataRepository.GetAll().Where(rc => (rc.CustomerGender == customer.CustomerGender) && (rc.CustomerAgeFrom <= customerage) && (rc.CustomerAgeTo >= customerage)).FirstOrDefault(); if (rc != null) { customer.NetPrice = rc.NetPrice; } } else { customer.CoveragePlan = " "; } _dataRepository.Add(customer); return(CreatedAtRoute( "Get", new { Id = customer.CustomerId }, customer)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public PagedList <WebShopProductModel> GetProducts(string searchText, int pageNumber, int pageSize) { var salespoint = _repo .GetAll <Salespoint>() .Single(sp => sp.Identifier == _settings.SalespointIdentifier); var saleProducts = salespoint.SaleProducts .Where(sp => searchText.IsNullOrEmpty() || sp.SearchableText.Contains(searchText)); return(new PagedSaleProductList(saleProducts, pageNumber, pageSize)); }
public IPagedList <SupplierModel> GetSuppliers(string searchText, int pageNumber, int pageSize) { return(_repo.GetAll <Supplier>() .Where(s => string.IsNullOrEmpty(searchText) || s.Name.Contains(searchText)) .Paged(pageNumber, pageSize, s => s.MapTo <SupplierModel>())); }
public IPagedList <ColorModel> SearchColors(SearchInput searchInput) { return(_repo.GetAll <Color>() .Where(c => string.IsNullOrEmpty(searchInput.SearchText) || c.Name.Contains(searchInput.SearchText)) .Paged(searchInput.PageNumber, searchInput.PageSize, c => c.MapTo <ColorModel>())); }
public IPagedList <ProductMasterModel> GetProducts(string searchText, int pageNumber, int pageSize) { return(_repo.GetAll <ProductMaster>() .Where(p => string.IsNullOrEmpty(searchText) || p.Name.Contains(searchText)) .Paged(pageNumber, pageSize, p => p.MapTo <ProductMasterModel>())); }
public IPagedList <ResellerModel> SearchResellers(string searchText, int pageNumber, int pageSize) { return(_repo.GetAll <Reseller>() .Where(r => string.IsNullOrEmpty(searchText) || r.Name.Contains(searchText)) .Paged(pageNumber, pageSize, r => r.MapTo <ResellerModel>())); }