//[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));
     }
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 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>()));
 }
Ejemplo n.º 4
0
 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>()));
 }
Ejemplo n.º 5
0
 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>()));
 }
Ejemplo n.º 6
0
 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>()));
 }