Ejemplo n.º 1
0
        public HttpResponseMessage AddTaxMethod(TaxMethodDisplay method)
        {
            var response = Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                var deleteMethod = _taxationContext.GetTaxMethodForCountryCode(method.CountryCode);
                if (deleteMethod != null)
                {
                    this.DeleteTaxMethod(deleteMethod.Key);
                }

                var provider = _taxationContext.GetProviderByKey(method.ProviderKey);

                var taxationGatewayMethod = provider.CreateTaxMethod(method.CountryCode, method.PercentageTaxRate);

                method.ToTaxMethod(taxationGatewayMethod.TaxMethod);

                provider.SaveTaxMethod(taxationGatewayMethod);
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, String.Format("{0}", ex.Message));
            }

            return(response);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage PutTaxMethod(TaxMethodDisplay method)
        {
            var response = Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                var provider = _taxationContext.GetProviderByKey(method.ProviderKey);

                var taxMethod = provider.TaxMethods.FirstOrDefault(x => x.Key == method.Key);

                if (taxMethod == null)
                {
                    var deleteMethod = _taxationContext.GetTaxMethodForCountryCode(method.CountryCode);
                    this.DeleteTaxMethod(deleteMethod.Key);
                    return(this.AddTaxMethod(method));
                }

                taxMethod = method.ToTaxMethod(taxMethod);

                provider.GatewayProviderService.Save(taxMethod);
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, string.Format("{0}", ex.Message));
            }

            return(response);
        }
Ejemplo n.º 3
0
        public HttpResponseMessage PutTaxMethod(TaxMethodDisplay method)
        {
            var response = Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                var provider = _taxationContext.CreateInstance(method.ProviderKey);

                var taxMethod = provider.TaxMethods.FirstOrDefault(x => x.Key == method.Key);

                taxMethod = method.ToTaxMethod(taxMethod);

                provider.GatewayProviderService.Save(taxMethod);
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, String.Format("{0}", ex.Message));
            }

            return(response);
        }