private static TaxRate DBMapping(DBTaxRate dbItem) { if (dbItem == null) return null; TaxRate item = new TaxRate(); item.TaxRateID = dbItem.TaxRateID; item.TaxCategoryID = dbItem.TaxCategoryID; item.CountryID = dbItem.CountryID; item.StateProvinceID = dbItem.StateProvinceID; item.Zip = dbItem.Zip; item.Percentage = dbItem.Percentage; return item; }
private static TaxRateCollection DBMapping(DBTaxRateCollection dbCollection) { if (dbCollection == null) { return(null); } TaxRateCollection collection = new TaxRateCollection(); foreach (DBTaxRate dbItem in dbCollection) { TaxRate item = DBMapping(dbItem); collection.Add(item); } return(collection); }
private static TaxRate DBMapping(DBTaxRate dbItem) { if (dbItem == null) { return(null); } var item = new TaxRate(); item.TaxRateId = dbItem.TaxRateId; item.TaxCategoryId = dbItem.TaxCategoryId; item.CountryId = dbItem.CountryId; item.StateProvinceId = dbItem.StateProvinceId; item.Zip = dbItem.Zip; item.Percentage = dbItem.Percentage; return(item); }
/// <summary> /// Inserts a tax rate /// </summary> /// <param name="taxRate">Tax rate</param> public void InsertTaxRate(TaxRate taxRate) { if (taxRate == null) { throw new ArgumentNullException("taxRate"); } taxRate.Zip = CommonHelper.EnsureNotNull(taxRate.Zip); taxRate.Zip = taxRate.Zip.Trim(); taxRate.Zip = CommonHelper.EnsureMaximumLength(taxRate.Zip, 50); _context.TaxRates.AddObject(taxRate); _context.SaveChanges(); if (this.CacheEnabled) { _cacheManager.RemoveByPattern(TAXRATE_PATTERN_KEY); } }
/// <summary> /// Updates the tax rate /// </summary> /// <param name="TaxRateID">The tax rate identifier</param> /// <param name="TaxCategoryID">The tax category identifier</param> /// <param name="CountryID">The country identifier</param> /// <param name="StateProvinceID">The state/province identifier</param> /// <param name="Zip">The zip</param> /// <param name="Percentage">The percentage</param> /// <returns>Tax rate</returns> public static TaxRate UpdateTaxRate(int TaxRateID, int TaxCategoryID, int CountryID, int StateProvinceID, string Zip, decimal Percentage) { if (Zip == null) { Zip = string.Empty; } if (!String.IsNullOrEmpty(Zip)) { Zip = Zip.Trim(); } DBTaxRate dbItem = DBProviderManager <DBTaxRateProvider> .Provider.UpdateTaxRate(TaxRateID, TaxCategoryID, CountryID, StateProvinceID, Zip, Percentage); TaxRate taxRate = DBMapping(dbItem); if (TaxRateManager.CacheEnabled) { NopCache.RemoveByPattern(TAXRATE_PATTERN_KEY); } return(taxRate); }
protected void SaveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { try { int taxRateId = 0; int.TryParse(lblTaxRateId.Text, out taxRateId); int taxCategoryId = int.Parse(this.ddlTaxCategory.SelectedItem.Value); int countryId = int.Parse(this.ddlCountry.SelectedItem.Value); int stateProvinceId = int.Parse(this.ddlStateProvince.SelectedItem.Value); string zipPostalCode = txtZip.Text; decimal percentage = txtPercentage.Value; TaxRate taxRate = this.TaxRateService.GetTaxRateById(taxRateId); if (taxRate != null) { taxRate.TaxCategoryId = taxCategoryId; taxRate.CountryId = countryId; taxRate.StateProvinceId = stateProvinceId; taxRate.Zip = zipPostalCode; taxRate.Percentage = percentage; this.TaxRateService.UpdateTaxRate(taxRate); } else { taxRate = new TaxRate() { TaxCategoryId = taxCategoryId, CountryId = countryId, StateProvinceId = stateProvinceId, Zip = zipPostalCode, Percentage = percentage }; this.TaxRateService.InsertTaxRate(taxRate); } BindGrid(); ToggleGrid(true); } catch (Exception exc) { ProcessException(exc); } } }
/// <summary> /// Updates the tax rate /// </summary> /// <param name="taxRate">Tax rate</param> public void UpdateTaxRate(TaxRate taxRate) { if (taxRate == null) throw new ArgumentNullException("taxRate"); taxRate.Zip = CommonHelper.EnsureNotNull(taxRate.Zip); taxRate.Zip = taxRate.Zip.Trim(); taxRate.Zip = CommonHelper.EnsureMaximumLength(taxRate.Zip, 50); if (!_context.IsAttached(taxRate)) _context.TaxRates.Attach(taxRate); _context.SaveChanges(); if (this.CacheEnabled) { _cacheManager.RemoveByPattern(TAXRATE_PATTERN_KEY); } }