public IActionResult TaxCategoryAdd(Models.Tax.TaxCategoryModel model) { //ensure that Avalara tax provider is active if (!(_taxService.LoadActiveTaxProvider(_workContext.CurrentCustomer) is AvalaraTaxProvider)) { return(new NullJsonResult()); } if (!_permissionService.Authorize(StandardPermissionProvider.ManageTaxSettings)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } var taxCategory = new TaxCategory(); taxCategory = model.ToEntity(taxCategory); _taxCategoryService.InsertTaxCategory(taxCategory); //save tax code type as generic attribute if (!string.IsNullOrEmpty(model.TypeId) && !model.TypeId.Equals(Guid.Empty.ToString())) { _genericAttributeService.SaveAttribute(taxCategory, AvalaraTaxDefaults.TaxCodeTypeAttribute, model.TypeId); } return(new NullJsonResult()); }
public IActionResult TaxCategoryAdd(Models.Tax.TaxCategoryModel model) { //ensure that Avalara tax provider is active if (!_taxPluginManager.IsPluginActive(AvalaraTaxDefaults.SystemName)) { return(new NullJsonResult()); } if (!_permissionService.Authorize(StandardPermissionProvider.ManageTaxSettings)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(ErrorJson(ModelState.SerializeErrors())); } var taxCategory = new TaxCategory(); taxCategory = model.ToEntity(taxCategory); _taxCategoryService.InsertTaxCategory(taxCategory); //save tax code type as generic attribute if (!string.IsNullOrEmpty(model.TypeId) && !model.TypeId.Equals(Guid.Empty.ToString())) { _genericAttributeService.SaveAttribute(taxCategory, AvalaraTaxDefaults.TaxCodeTypeAttribute, model.TypeId); } return(Json(new { Result = true })); }
public async Task<IActionResult> CategoryAdd( TaxCategoryModel model) { if (!ModelState.IsValid) { return Json(new DataSourceResult { Errors = ModelState.SerializeErrors() }); } var taxCategory = new TaxCategory(); taxCategory = model.ToEntity(taxCategory); await _taxCategoryService.InsertTaxCategory(taxCategory); return new NullJsonResult(); }
public ActionResult CategoryAdd([Bind(Exclude = "Id")] TaxCategoryModel model, GridCommand command) { if (!ModelState.IsValid) { var modelStateErrors = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage); return(Content(modelStateErrors.FirstOrDefault())); } var taxCategory = new TaxCategory(); taxCategory = model.ToEntity(taxCategory); _taxCategoryService.InsertTaxCategory(taxCategory); return(Categories(command)); }
public ActionResult CategoryAdd([Bind(Exclude = "Id")] TaxCategoryModel model, GridCommand command) { if (_permissionService.Authorize(StandardPermissionProvider.ManageTaxSettings)) { if (!ModelState.IsValid) { var modelStateErrors = this.ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage); return(Content(modelStateErrors.FirstOrDefault())); } var taxCategory = new TaxCategory(); taxCategory = model.ToEntity(taxCategory); _taxCategoryService.InsertTaxCategory(taxCategory); } return(Categories(command)); }
public virtual IActionResult CategoryAdd(TaxCategoryModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageTaxSettings)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(ErrorJson(ModelState.SerializeErrors())); } var taxCategory = new TaxCategory(); taxCategory = model.ToEntity(taxCategory); _taxCategoryService.InsertTaxCategory(taxCategory); return(Json(new { Result = true })); }
public virtual ActionResult CategoryAdd([Bind(Exclude = "Id")] TaxCategoryModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageTaxSettings)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } var taxCategory = new TaxCategory(); taxCategory = model.ToEntity(taxCategory); _taxCategoryService.InsertTaxCategory(taxCategory); return(new NullJsonResult()); }
public ActionResult CategoryAdd([Bind(Exclude = "Id")] TaxCategoryModel model, GridCommand command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageTaxSettings)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(new JsonResult { Data = "error" }); } var taxCategory = new TaxCategory(); taxCategory = model.ToEntity(taxCategory); _taxCategoryService.InsertTaxCategory(taxCategory); return(Categories(command)); }
/// <summary> /// Inserts a tax category /// </summary> /// <param name="taxCategory">Tax category</param> public void InsertTaxCategory([FromBody] TaxCategory taxCategory) { _taxCategoryService.InsertTaxCategory(taxCategory); }