public ShipMethodDisplay PutShipMethod(ShipMethodDisplay method) { var provider = _shippingContext.GetProviderByKey(method.ProviderKey); var shippingMethod = provider.ShipMethods.FirstOrDefault(x => x.Key == method.Key); shippingMethod = method.ToShipMethod(shippingMethod); provider.GatewayProviderService.Save(shippingMethod); return(shippingMethod.ToShipMethodDisplay()); }
public ShipFixedRateTableDisplay GetShipFixedRateTable(ShipMethodDisplay method) { var fixedMethod = (IFixedRateShippingGatewayMethod)_fixedRateShippingGatewayProvider.GetShippingGatewayMethod(method.Key, method.ShipCountryKey); if (fixedMethod == null) throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); var rateTable = fixedMethod.RateTable.ToShipFixedRateTableDisplay(); // TODO RSS - this is pretty hacky rateTable.ShipCountryKey = fixedMethod.ShipMethod.ShipCountryKey; return rateTable; }
public HttpResponseMessage DeleteShipMethod(ShipMethodDisplay method) { var shippingMethodService = ((ServiceContext)MerchelloContext.Services).ShipMethodService; var methodToDelete = shippingMethodService.GetByKey(method.Key); if (methodToDelete == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } shippingMethodService.Delete(methodToDelete); return(Request.CreateResponse(HttpStatusCode.OK)); }
public ShipFixedRateTableDisplay GetShipFixedRateTable(ShipMethodDisplay method) { var fixedMethod = (IFixedRateShippingGatewayMethod)_fixedRateShippingGatewayProvider.GetShippingGatewayMethod(method.Key, method.ShipCountryKey); if (fixedMethod == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } var rateTable = fixedMethod.RateTable.ToShipFixedRateTableDisplay(); // TODO RSS - this is pretty hacky rateTable.ShipCountryKey = fixedMethod.ShipMethod.ShipCountryKey; return(rateTable); }
public ShipMethodDisplay AddShipMethod(ShipMethodDisplay method) { ////var response = Request.CreateResponse(HttpStatusCode.OK); var provider = _shippingContext.GetProviderByKey(method.ProviderKey); var gatewayResource = provider.ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == method.ServiceCode); var shipCountry = _shipCountryService.GetByKey(method.ShipCountryKey); var shippingGatewayMethod = provider.CreateShippingGatewayMethod( gatewayResource, shipCountry, method.Name); provider.SaveShippingGatewayMethod(shippingGatewayMethod); return(shippingGatewayMethod.ToShipMethodDisplay()); }
public ShipMethodDisplay AddShipMethod(ShipMethodDisplay method) { ////var response = Request.CreateResponse(HttpStatusCode.OK); var provider = _shippingContext.GetProviderByKey(method.ProviderKey); var gatewayResource = provider.ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == method.ServiceCode); var shipCountry = _shipCountryService.GetByKey(method.ShipCountryKey); var shippingGatewayMethod = provider.CreateShippingGatewayMethod( gatewayResource, shipCountry, method.Name); provider.SaveShippingGatewayMethod(shippingGatewayMethod); return shippingGatewayMethod.ToShipMethodDisplay(); }
public HttpResponseMessage PutShipMethod(ShipMethodDisplay method) { var response = Request.CreateResponse(HttpStatusCode.OK); try { var provider = _shippingContext.CreateInstance(method.ProviderKey); var shippingMethod = provider.ShipMethods.FirstOrDefault(x => x.Key == method.Key); shippingMethod = method.ToShipMethod(shippingMethod); provider.GatewayProviderService.Save(shippingMethod); } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, String.Format("{0}", ex.Message)); } return(response); }
public HttpResponseMessage AddShipMethod(ShipMethodDisplay method) { var response = Request.CreateResponse(HttpStatusCode.OK); try { var provider = _shippingContext.CreateInstance(method.ProviderKey); var gatewayResource = provider.ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == method.ServiceCode); var shipCountry = _shipCountryService.GetByKey(method.ShipCountryKey); var shippingGatewayMethod = provider.CreateShippingGatewayMethod(gatewayResource, shipCountry, method.Name); provider.SaveShippingGatewayMethod(shippingGatewayMethod); } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, String.Format("{0}", ex.Message)); } return(response); }
public ShipMethodDisplay PutShipMethod(ShipMethodDisplay method) { var provider = _shippingContext.GetProviderByKey(method.ProviderKey); var shippingMethod = provider.ShipMethods.FirstOrDefault(x => x.Key == method.Key); shippingMethod = method.ToShipMethod(shippingMethod); provider.GatewayProviderService.Save(shippingMethod); return shippingMethod.ToShipMethodDisplay(); }
public HttpResponseMessage DeleteShipMethod(ShipMethodDisplay method) { var shippingMethodService = ((ServiceContext)MerchelloContext.Services).ShipMethodService; var methodToDelete = shippingMethodService.GetByKey(method.Key); if (methodToDelete == null) return Request.CreateResponse(HttpStatusCode.NotFound); shippingMethodService.Delete(methodToDelete); return Request.CreateResponse(HttpStatusCode.OK); }