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); }
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); }
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); }