public override int SavePickupLocation(InsertCourierLookupRequest_V01 request) { var retValue = 0; if (request != null || request.CourierStoreNumber > 0 || !string.IsNullOrEmpty(request.CountryCode)) { try { // Call the Shipping service to Insert a new Pickup location var service = ServiceClientProvider.GetShippingServiceProxy(); var response = service.InsertCourierLookup(new InsertCourierLookupRequest1(request)).InsertCourierLookupResult as InsertCourierLookupResponse_V01; if (response != null && response.Status == ServiceResponseStatusType.Success) { return(response.ID); } } catch (Exception ex) { LoggerHelper.Error(string.Format("SavePickupLocation error: Country {0}, CourierStoreNumber {1}, error: {2}", request.CountryCode, request.CourierStoreNumber, ex.ToString())); } } return(retValue); }
protected void ContinueChanges_Click(object sender, EventArgs e) { lblErrors.Text = ""; if (SourceCommand.Mode == PickupCommandType.DELETE) { try { if (WorkedUponDeliveryOptionId == 0) { int value = 0; int.TryParse(Session["IDToDelete"].ToString(), out value); WorkedUponDeliveryOptionId = value; } } catch { WorkedUponDeliveryOptionId = int.Parse(Session["IDToDelete"].ToString()); } int returnId = (Page as ProductsBase).GetShippingProvider().DeletePickupLocationsPreferences((Page as ProductsBase).DistributorID, WorkedUponDeliveryOptionId, (Page as ProductsBase).CountryCode); OnPickupPreferenceDeleted(this, new DeliveryOptionEventArgs(WorkedUponDeliveryOptionId, string.Empty)); } else { var jsonResponse = JObject.Parse(hdnMapResponse.Value); // Validate if could retrieve the address from the 7Eleven map if (jsonResponse == null) { lblErrors.Text = "Error retrieving map response."; return; } if (jsonResponse != null && jsonResponse["error"] != null) { lblErrors.Text = jsonResponse["error"].ToString(); return; } // Save Address with jsonResponse var pickupLocationId = jsonResponse["storeCode"] != null ? (int)jsonResponse["storeCode"] : -1; if (pickupLocationId < 0) { lblErrors.Text = PlatformResources.GetGlobalResourceString("ErrorMessage", "NoPickUpLocation"); return; } bool isSession = !HLConfigManager.Configurations.CheckoutConfiguration.SavePickupFromCourierPreferences; string branchName = jsonResponse["storeName"] != null ? jsonResponse["storeName"].ToString() : string.Empty; string addressDetails = jsonResponse["address"] != null ? jsonResponse["address"].ToString() : string.Empty; string[] parts = addressDetails.Split(' '); string postalCode = string.Empty; string province = string.Empty; string subdistrict = string.Empty; string district = string.Empty; string address = string.Empty; if (parts.Length > 4) { postalCode = parts[parts.Length - 1].ToString(); province = parts[parts.Length - 2].ToString(); subdistrict = parts[parts.Length - 3].ToString(); district = parts[parts.Length - 4].ToString(); StringBuilder builder = new StringBuilder(); var addressValue = parts.Take(parts.Length - 4); foreach (string add in addressValue) { builder.Append(add); builder.Append(" "); } address = builder.ToString(); } else if (parts.Length == 4) { postalCode = parts[parts.Length - 1].ToString(); province = parts[parts.Length - 2].ToString(); subdistrict = parts[parts.Length - 3].ToString(); district = parts[parts.Length - 4].ToString(); address = subdistrict; } var freightCodeAndWarehouse = ProductsBase.GetShippingProvider().GetFreightCodeAndWarehouse(new ShippingAddress_V01() { Address = new Address_V01() { StateProvinceTerritory = "*" } }); // Create var courierLocation = new InsertCourierLookupRequest_V01() { Locale = this.Locale, CountryCode = this.CountryCode, FreightCode = freightCodeAndWarehouse[0], WarehouseCode = freightCodeAndWarehouse[1], CourierStoreNumber = pickupLocationId, State = province, CourierStoreName = branchName, Zip = postalCode, City = district, Street1 = address, Street2 = subdistrict, CourierType = DEFAULT_COURIERTYPE, CourierStoreId = pickupLocationId.ToString(), AdditionalInformation = GetLocalResourceObject("DefaultAdditionalInfo") as string }; int retValue = ProductsBase.GetShippingProvider().SavePickupLocation(courierLocation); if (retValue == pickupLocationId) { // Save PickupLocationPreference int returnId = ProductsBase.GetShippingProvider(). SavePickupLocationsPreferences(DistributorID, isSession, pickupLocationId, string.Format("{0} #{1}", GetLocalResourceObject("DefaultNickname") as string, pickupLocationId), branchName, CountryCode, false, DEFAULT_COURIERTYPE); if (returnId == -2) //duplicate nickname { lblErrors.Text = PlatformResources.GetGlobalResourceString("ErrorMessage", "DuplicateAddressNickname"); return; } if (returnId == -3) //duplicate pickuplocation { lblErrors.Text = PlatformResources.GetGlobalResourceString("ErrorMessage", "DuplicatePickupLocation"); return; } // Add PickupLocation to cache and select OnPickupPreferenceCreated(this, new DeliveryOptionEventArgs(returnId, DEFAULT_COURIERTYPE)); } else { lblErrors.Text = PlatformResources.GetGlobalResourceString("ErrorMessage", "CannotSavePickupLocation"); return; } } ClosePopup(); }