public HttpResponseMessage AddFixedRateShipMethod(FixedRateShipMethodDisplay method) { var response = Request.CreateResponse(HttpStatusCode.OK); try { var shipCountry = _shipCountryService.GetByKey(method.ShipMethod.ShipCountryKey); var provider = _fixedRateShippingGatewayProvider; var rateTableType = FixedRateShippingGatewayMethod.QuoteType.VaryByWeight; if (method.GatewayResource.ServiceCode == "VBP") { rateTableType = FixedRateShippingGatewayMethod.QuoteType.VaryByPrice; } var merchelloGwShipMethod = (IFixedRateShippingGatewayMethod)provider.CreateShipMethod(rateTableType, shipCountry, method.ShipMethod.Name); merchelloGwShipMethod = method.ToFixedRateShipMethod(merchelloGwShipMethod); provider.SaveShippingGatewayMethod(merchelloGwShipMethod); } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, String.Format("{0}", ex.Message)); } return response; }
public HttpResponseMessage PutFixedRateShipMethod(FixedRateShipMethodDisplay method) { var response = Request.CreateResponse(HttpStatusCode.OK); try { var shipCountry = _shipCountryService.GetByKey(method.ShipMethod.ShipCountryKey); var provider = _fixedRateShippingGatewayProvider; var merchelloMethod = (IFixedRateShippingGatewayMethod)provider.GetAllShippingGatewayMethods(shipCountry).FirstOrDefault(m => m.ShipMethod.Key == method.ShipMethod.Key); if (merchelloMethod != null) { merchelloMethod = method.ToFixedRateShipMethod(merchelloMethod); } else { return Request.CreateResponse(HttpStatusCode.NotFound); } provider.SaveShippingGatewayMethod(merchelloMethod); } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, String.Format("{0}", ex.Message)); } return response; }