コード例 #1
0
        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());
        }
コード例 #2
0
        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 }));
        }
コード例 #3
0
ファイル: TaxController.cs プロジェクト: huyhuana/grandnode-1
        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();
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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 }));
        }
コード例 #7
0
        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());
        }
コード例 #8
0
        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));
        }
コード例 #9
0
 /// <summary>
 /// Inserts a tax category
 /// </summary>
 /// <param name="taxCategory">Tax category</param>
 public void InsertTaxCategory([FromBody] TaxCategory taxCategory)
 {
     _taxCategoryService.InsertTaxCategory(taxCategory);
 }