public TaxCategory SaveInfo() { TaxCategory taxCategory = this.TaxCategoryService.GetTaxCategoryById(this.TaxCategoryId); if (taxCategory != null) { taxCategory.Name = txtName.Text; taxCategory.DisplayOrder = txtDisplayOrder.Value; taxCategory.UpdatedOn = DateTime.UtcNow; this.TaxCategoryService.UpdateTaxCategory(taxCategory); } else { DateTime now = DateTime.UtcNow; taxCategory = new TaxCategory() { Name = txtName.Text, DisplayOrder = txtDisplayOrder.Value, CreatedOn = now, UpdatedOn = now }; this.TaxCategoryService.InsertTaxCategory(taxCategory); } return taxCategory; }
private static TaxCategory DBMapping(DBTaxCategory dbItem) { if (dbItem == null) return null; TaxCategory item = new TaxCategory(); item.TaxCategoryID = dbItem.TaxCategoryID; item.Name = dbItem.Name; item.DisplayOrder = dbItem.DisplayOrder; item.CreatedOn = dbItem.CreatedOn; item.UpdatedOn = dbItem.UpdatedOn; return item; }
/// <summary> /// Updates the tax category /// </summary> /// <param name="taxCategory">Tax category</param> public void UpdateTaxCategory(TaxCategory taxCategory) { if (taxCategory == null) throw new ArgumentNullException("taxCategory"); taxCategory.Name = CommonHelper.EnsureNotNull(taxCategory.Name); taxCategory.Name = CommonHelper.EnsureMaximumLength(taxCategory.Name, 100); if (!_context.IsAttached(taxCategory)) _context.TaxCategories.Attach(taxCategory); _context.SaveChanges(); if (this.CacheEnabled) { _cacheManager.RemoveByPattern(TAXCATEGORIES_PATTERN_KEY); } }