public ActionResult ChangePackageDeliveryAddress(int packageId, int deliveryAddressId) { var request = new ChangePackageDeliveryAddressRequest { PackageId = packageId, DeliverAddressId = deliveryAddressId }; var response = this.packagesService.ChangePackageDeliveryAddress(request); var jsonNetResult = new JsonNetResult { Formatting = (Formatting)Newtonsoft.Json.Formatting.Indented, Data = new { Country = Countries.ResourceManager.GetString(response.CountryCode), Message = response.Message, MessageType = response.MessageType.ToString() } }; return jsonNetResult; }
/// <summary> /// The change package delivery address. /// </summary> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="ChangePackageDeliveryAddressResponse"/>. /// </returns> public ChangePackageDeliveryAddressResponse ChangePackageDeliveryAddress(ChangePackageDeliveryAddressRequest request) { try { var package = this.packageRepository.GetPackageById(request.PackageId); package.DeliveryAddressId = request.DeliverAddressId; this.packageRepository.UpdatePackage(package); var addr = this.addressRepository.GetDeliveryAddressDetails(request.DeliverAddressId); return new ChangePackageDeliveryAddressResponse { CountryCode = addr.Country.Code, MessageType = MessageType.Success, Message = string.Format( CommonResources.PackageDeliveryAddressChanged, package.Id) }; } catch (Exception ex) { this.Logger.Log(ex.Message); return new ChangePackageDeliveryAddressResponse { MessageType = MessageType.Error, Message = CommonResources.ChangePackageDeliveryAddressError }; } }