Esempio n. 1
0
        public virtual ActionResult GetQuickReturnLabelCost(string orderNumber)
        {
            LogI("GetQuickReturnLabelCost, orderNumber=" + orderNumber);

            var messages = MailViewModel.ValidateQuickReturnLabel(Db, orderNumber);

            ShippingMethodViewModel quickRate = null;

            if (!messages.Any())
            {
                quickRate = MailViewModel.GetQuickPrintLabelRate(Db,
                                                                 DbFactory,
                                                                 ServiceFactory,
                                                                 ShippingService,
                                                                 AccessManager.Company,
                                                                 LogService,
                                                                 Time,
                                                                 WeightService,
                                                                 orderNumber);

                if (quickRate == null)
                {
                    messages.Add(MessageString.Warning("System hasn\'t received any rates"));
                }
            }

            LogI("ChipestRate: " + (quickRate != null ? quickRate.Id.ToString() + ", cost=" + quickRate.Rate : ""));

            return(JsonGet(new ValueMessageResult <ShippingMethodViewModel>()
            {
                IsSuccess = quickRate != null,
                Data = quickRate,
                Messages = messages,
            }));
        }
Esempio n. 2
0
        public IActionResult AddShippingMethod(int id)
        {
            var model = new ShippingMethodViewModel {
                CarrierId = id
            };

            return(this.View(model));
        }
Esempio n. 3
0
        public async Task <IActionResult> AddShippingMethod(ShippingMethodViewModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            await this.shippingService.AddShippingMethodAsync(input.CarrierId, input.Name);

            return(this.RedirectToAction(nameof(this.ManageShippingMethods), new { id = input.CarrierId }));
        }
Esempio n. 4
0
        public async Task WHEN_Passing_Valid_Parameters_SHOULD_Update_ShippingMethod()
        {
            //Arrange
            var updatedShippingMethod = new ShippingMethodViewModel
            {
                Name = GetRandom.String(32),
                ShippingProviderId = Guid.NewGuid(),
                Cost = GetRandom.PositiveInt(100).ToString(),
            };

            var mock = new Mock <IFulfillmentMethodRepository>();

            mock.Setup(repo => repo.GetCalculatedFulfillmentMethods(It.IsAny <GetShippingMethodsParam>()))
            .ReturnsAsync(new List <FulfillmentMethod>
            {
                new FulfillmentMethod(),
                new FulfillmentMethod
                {
                    Name = updatedShippingMethod.Name,
                    ShippingProviderId = updatedShippingMethod.ShippingProviderId
                }
            });

            _container.Use(mock);

            var cart    = CreateBasicCart();
            var service = CreateCheckoutService(cart);

            // Act
            var param = new UpdateCheckoutCartParam
            {
                GetCartParam = CreateGetCartParam(),
                UpdateValues = CreateUpdateOperation("ShippingMethod", updatedShippingMethod),
                CurrentStep  = GetRandom.Int(),
                IsGuest      = GetRandom.Boolean()
            };
            var processedCart = await service.UpdateCheckoutCartAsync(param);

            //Assert
            processedCart.Cart.Should().NotBeNull();
            processedCart.Cart.ShippingMethod.Name.Should().BeEquivalentTo(updatedShippingMethod.Name);
            processedCart.Cart.ShippingMethod.ShippingProviderId.ShouldBeEquivalentTo(updatedShippingMethod.ShippingProviderId);
        }
Esempio n. 5
0
        public ActionResult Edit(ShippingMethodViewModel model, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(model));
                }

                var byId = _paymentMethodService.Get(x => x.Id == model.Id);

                var modelMap = Mapper.Map(model, byId);
                _paymentMethodService.Update(modelMap);

                //Update Localized
                foreach (var localized in model.Locales)
                {
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Name, localized.Name, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId);
                }


                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.Name)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("ShippingMethod.Edit: ", ex.Message));
                return(View(model));
            }

            return(action);
        }
Esempio n. 6
0
        public static ShippingMethodViewModel GetQuickPrintLabelRate(IUnitOfWork db,
                                                                     IDbFactory dbFactory,
                                                                     IServiceFactory serviceFactory,
                                                                     IShippingService shippingService,
                                                                     CompanyDTO company,
                                                                     ILogService log,
                                                                     ITime time,
                                                                     IWeightService weightService,
                                                                     string orderNumber)
        {
            var companyAddress = new CompanyAddressService(company);

            var model = MailViewModel.GetByOrderId(db, weightService, orderNumber);

            model.IsAddressSwitched  = true;
            model.FromAddress        = model.ToAddress;
            model.ToAddress          = MailViewModel.GetFromAddress(companyAddress.GetReturnAddress(MarketIdentifier.Empty()), MarketplaceType.Amazon);
            model.ShipmentProviderId = (int)ShipmentProviderType.Stamps;
            model.ReasonCode         = (int)MailLabelReasonCodes.ReturnLabelReasonCode;

            var rateProvider = serviceFactory.GetShipmentProviderByType((ShipmentProviderType)model.ShipmentProviderId,
                                                                        log,
                                                                        time,
                                                                        dbFactory,
                                                                        weightService,
                                                                        company.ShipmentProviderInfoList,
                                                                        null,
                                                                        null,
                                                                        null,
                                                                        null);

            var shippingOptionsResult           = model.GetShippingOptionsModel(db, time, log, rateProvider, shippingService, weightService);
            ShippingMethodViewModel chipestRate = null;

            if (shippingOptionsResult.IsSuccess)
            {
                chipestRate = shippingOptionsResult.Data.OrderBy(o => o.Rate).FirstOrDefault();
            }
            return(chipestRate);
        }
        internal static Mock <ICartViewModelFactory> MockGetShippingMethodViewModel()
        {
            var mock = new Mock <ICartViewModelFactory>();

            mock.Setup(m => m.GetShippingMethodViewModel(It.IsNotNull <FulfillmentMethod>(), It.IsNotNull <CultureInfo>()))
            .Returns((FulfillmentMethod fm, CultureInfo ci) =>
            {
                var vm = new ShippingMethodViewModel
                {
                    Cost                       = fm.Cost.ToString("C2"),
                    CostDouble                 = fm.Cost,
                    DisplayName                = fm.Name,
                    Name                       = fm.Name,
                    ShippingProviderId         = fm.ShippingProviderId,
                    ExpectedDaysBeforeDelivery = GetRandom.String(5)
                };

                return(vm);
            });

            return(mock);
        }
 public ShowShippingMethodViewCommand(ShippingMethodViewModel viewModel)
 {
     m_ViewModel = viewModel;
 }
Esempio n. 9
0
 public virtual bool FilterShippingMethodView(ShippingMethodViewModel sippingMethod)
 {
     return(sippingMethod.FulfillmentMethodType == FulfillmentMethodType.Shipping || sippingMethod.FulfillmentMethodType == FulfillmentMethodType.PickUp);
 }
        protected virtual async Task <FulfillmentMethod> GetFulfillmentMethodAsync(Overture.ServiceModel.Orders.Cart cart, ShippingMethodViewModel shippingMethodViewModel)
        {
            var param = new GetShippingMethodsParam
            {
                CartName    = cart.Name,
                CustomerId  = cart.CustomerId,
                CultureInfo = new CultureInfo(cart.CultureName),
                Scope       = cart.ScopeId
            };

            var fulfillmentMethods = await FulfillmentMethodRepository.GetCalculatedFulfillmentMethods(param);

            var fulfillmentMethod = fulfillmentMethods.FirstOrDefault(method =>
                                                                      method.Name == shippingMethodViewModel.Name &&
                                                                      method.ShippingProviderId == shippingMethodViewModel.ShippingProviderId);

            if (fulfillmentMethod == null)
            {
                throw new ComposerException(new ErrorViewModel
                {
                    ErrorCode    = "",
                    ErrorMessage = "Unable to find any shipment provider matching the provided parameters."
                });
            }

            return(fulfillmentMethod);
        }
        protected virtual async Task UpdateShippingMethod(Overture.ServiceModel.Orders.Cart cart, ShippingMethodViewModel shippingMethodViewModel)
        {
            if (shippingMethodViewModel == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(shippingMethodViewModel.Name))
            {
                return;
            }

            var shipment = cart.Shipments.FirstOrDefault();

            if (shipment == null)
            {
                return;
            }

            shipment.FulfillmentMethod = await GetFulfillmentMethodAsync(cart, shippingMethodViewModel);
        }
 public ShippingMethodGridView(ShippingMethodViewModel shippingMethodViewModel)
 {
     InitializeComponent();
     DataContext = shippingMethodViewModel;
     //shippingMethodViewModel.LoadData();
 }
Esempio n. 13
0
        protected virtual async Task UpdateShippingMethod(Overture.ServiceModel.Orders.Cart cart, ShippingMethodViewModel shippingMethodViewModel)
        {
            if (string.IsNullOrEmpty(shippingMethodViewModel?.Name))
            {
                return;
            }

            var shipment = cart.Shipments.FirstOrDefault();

            if (shipment == null)
            {
                return;
            }

            if (shipment.PickUpLocationId.HasValue)
            {
                shipment.PickUpLocationId = null;
                shipment.Address          = null;
                var fulfillmentLocation = await InventoryLocationProvider.GetFulfillmentLocationAsync(new GetFulfillmentLocationParam
                {
                    Scope = cart.ScopeId
                }).ConfigureAwait(false);

                shipment.FulfillmentLocationId = fulfillmentLocation.Id;
            }

            shipment.FulfillmentMethod = await GetFulfillmentMethodAsync(cart, shippingMethodViewModel);
        }