/// <summary>
            /// Used to get the shipment options for a shipment of @nrOfPackages, weighing @weightInGrams headed for @postCode
            /// using @deliveryType
            /// </summary>
            public ProductsWrapper GetFreightOptions(int nrOfPackages, int weightInGrams, string postCode, DeliveryType deliveryType)
            {
                // Create the receiver
                Receiver Receiver = new Receiver
                {
                    PostCode    = postCode,
                    CountryCode = "NO"
                };

                //Create WebshopLine( goods line)
                List <WebShopLine> lines = new List <WebShopLine>();
                WebShopLine        ln    = new WebShopLine
                {
                    NumberOfPackages = nrOfPackages,
                    PackageWeight    = weightInGrams
                };

                lines.Add(ln);

                //Create shipment
                WebShopShipment shipment = new WebShopShipment
                {
                    WebShopId = 1209,
                    Shopper   = Receiver,
                    CODAmount = 0,
                    Lines     = lines.ToArray()
                };
                // Create an instance of ProductsWrapper class to hold the available products that is returned from ShipAdvisor
                ProductsWrapper FreightProducts = new ProductsWrapper();

                FreightProducts = shipAdvisor.GetFreightProductsForShipment(shipment, (int)deliveryType);

                return(FreightProducts);
            }
Beispiel #2
0
        public IActionResult Products()
        {
            int?uId = HttpContext.Session.GetInt32("UserId");

            if (uId == null)
            {
                return(RedirectToAction("LogReg"));
            }

            ProductsWrapper WMod = new ProductsWrapper
            {
                LoggedUser = _context.Users
                             .Include(u => u.Products)
                             .ThenInclude(s => s.Orders)
                             .ThenInclude(sn => sn.Customer)
                             .FirstOrDefault(u => u.UserId == uId),
                AllProducts = _context.Products
                              .Include(s => s.User)
                              .Include(s => s.Orders)
                              .ThenInclude(sn => sn.Customer)
                              .Where(s => s.UserId != uId)
                              .ToList(),
            };

            return(View("Products", WMod));
        }
            /// <summary>
            /// Used to get the @nrOfDropPoints droppoints for a shipment of @nrOfPackages, weighing @weightInGrams headed for @postCode
            /// using @deliveryType
            /// </summary>
            public DropPointData[] GetDropPoints(int nrOfPackages, int weightInGrams, string postCode, int nrOfDropPoints, DeliveryType deliveryType)
            {
                ProductsWrapper FreightProducts = GetFreightOptions(nrOfPackages, weightInGrams, postCode, deliveryType);

                var cID = FreightProducts.ProductInfoList[0].ConceptId;

                DropPointData[] dps = shipAdvisor.SearchForDropPoints((int)cID, "11685000025", "NO", "", postCode, "", nrOfDropPoints);


                return(dps);
            }