Beispiel #1
0
        protected void rptWarehouseList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var warehouseInventory = e.Item.DataItem as Inventory;

            if (warehouseInventory == null)
            {
                return;
            }

            var warehouse = WarehouseHelper.GetWarehouse(warehouseInventory.WarehouseCode);

            if (warehouse == null)
            {
                return;
            }

            SetWarehouseName(e, warehouse);
            SetWarehouseAddress(e, warehouse, warehouseInventory);
            SetPickUpButton(e, warehouse, warehouseInventory);
        }
 private void ContentEvents_PublishedContent(object sender, EPiServer.ContentEventArgs e)
 {
     if (e.Content is StoreLocationPage)
     {
         var storeLocation = e.Content as StoreLocationPage;
         // Update if not set already and warehouse code is added
         if (!string.IsNullOrEmpty(storeLocation.WarehouseCode) && string.IsNullOrEmpty(storeLocation.Address))
         {
             // Find the warehouse
             var warehouse = WarehouseHelper.GetWarehouse(storeLocation.WarehouseCode);
             if (warehouse != null)
             {
                 StoreLocationPage updatedPage = storeLocation.CreateWritableClone() as StoreLocationPage;
                 // Map properties to page
                 updatedPage.Address   = SetupAddress(warehouse.ContactInformation.Line1, warehouse.ContactInformation.Line2);
                 updatedPage.City      = warehouse.ContactInformation.City;
                 updatedPage.PostCode  = warehouse.ContactInformation.PostalCode;
                 updatedPage.State     = warehouse.ContactInformation.State;
                 updatedPage.Country   = warehouse.ContactInformation.CountryName;
                 updatedPage.Telephone = warehouse.ContactInformation.DaytimePhoneNumber;
                 updatedPage.Fax       = warehouse.ContactInformation.FaxNumber;
                 updatedPage.Email     = warehouse.ContactInformation.Email;
                 // Update
                 var repository = ServiceLocator.Current.GetInstance <IContentRepository>();
                 repository.Save(updatedPage, EPiServer.DataAccess.SaveAction.ForceCurrentVersion);
             }
         }
     }
 }
Beispiel #3
0
        private bool IsValidSingleShippment()
        {
            // Check valid line item for Single Shipment
            if (Cart.OrderForms.Count > 0)
            {
                List <string> warehouseCodes = new List <string>();
                var           lineItems      = Cart.OrderForms[0].LineItems;
                foreach (LineItem lineItem in lineItems)
                {
                    if (!warehouseCodes.Contains(lineItem.WarehouseCode))
                    {
                        warehouseCodes.Add(lineItem.WarehouseCode);
                    }
                }

                // Cart only has one warehouse instore pickup
                if (warehouseCodes.Count == 1)
                {
                    // Shipping method is "In store pickup", add address to Cart & Shipment
                    IWarehouse warehouse = WarehouseHelper.GetWarehouse(warehouseCodes.FirstOrDefault());

                    if (!warehouse.IsFulfillmentCenter && warehouse.IsPickupLocation)
                    {
                        Shipment.WarehouseCode = warehouse.Code;

                        if (CartHelper.FindAddressByName(warehouse.Name) == null)
                        {
                            var address = warehouse.ContactInformation.ToOrderAddress();
                            address.Name = warehouse.Name;
                            Cart.OrderAddresses.Add(address);
                        }

                        Shipment.ShippingAddressId  = warehouse.Name;
                        Shipment.ShippingMethodName = ShippingManager.PickupShippingMethodName;

                        var instorepickupShippingMethod = ShippingManager.GetShippingMethods("en").ShippingMethod.ToArray().Where(m => m.Name.Equals(ShippingManager.PickupShippingMethodName)).FirstOrDefault();
                        if (instorepickupShippingMethod != null)
                        {
                            Shipment.ShippingMethodId = instorepickupShippingMethod.ShippingMethodId;
                        }

                        Cart.AcceptChanges();
                    }
                }
                else
                {
                    foreach (string warehouseCode in warehouseCodes)
                    {
                        IWarehouse warehouse = WarehouseHelper.GetWarehouse(warehouseCode);
                        if (warehouse != null && warehouse.IsPickupLocation)
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Beispiel #4
0
        public ActionResult Create()
        {
            OrderShipmentModel newShipment = SessionHelper.Shipment;

            if (newShipment == null)
            {
                newShipment = new OrderShipmentModel
                {
                    DeliveryDate   = DateTime.Now,
                    CompanyId      = AuthenticationHelper.CompanyId.Value,
                    OrderShipments = new List <OrderShipmentLine>()
                };
                SessionHelper.Shipment = newShipment;
            }

            newShipment.Customers = CustomerHelper.GetActiveCustomersCombo(newShipment.DeliveryDate);
            if (newShipment.Customers != null && newShipment.Customers.Count() > 0)
            {
                newShipment.CustomerId = newShipment.CustomerId > 0 ? newShipment.CustomerId : 0;
                newShipment.Customers.Add(new SelectListItem {
                    Text = "-- Select --", Value = "0"
                });
                newShipment.CustomerSites = CustomerHelper.GetCustomerSitesCombo(newShipment.CustomerId);
                if (newShipment.CustomerSites != null && newShipment.CustomerSites.Count() > 0)
                {
                    newShipment.CustomerSiteId = newShipment.CustomerSiteId > 0 ? newShipment.CustomerSiteId : 0;
                    newShipment.CustomerSites.Add(new SelectListItem {
                        Text = "-- Select --", Value = "0"
                    });
                }
            }

            newShipment.Orders = OrderHelper.GetOrdersCombo();
            if (newShipment.Orders != null && newShipment.Orders.Count() > 0)
            {
                newShipment.OrderId = newShipment.OrderId > 0 ? newShipment.OrderId : 0;
                newShipment.Orders.Add(new SelectListItem {
                    Text = "-- Select --", Value = "0"
                });
            }

            newShipment.Warehouses = WarehouseHelper.GetWarehousesCombo(SessionHelper.SOBId);
            if (newShipment.Warehouses != null && newShipment.Warehouses.Count() > 0)
            {
                newShipment.WarehouseId = newShipment.WarehouseId > 0 ? newShipment.WarehouseId : Convert.ToInt64(newShipment.Warehouses.First().Value);
            }

            newShipment.DeliveryNo = "New";
            SessionHelper.Shipment = newShipment;
            SessionHelper.Shipment.OrderShipments = ShipmentHelper.GetShipment(newShipment.WarehouseId, newShipment.CustomerId, newShipment.CustomerSiteId, newShipment.OrderId).OrderShipments;

            return(View("Edit", newShipment));
        }
Beispiel #5
0
        public static void Test0()
        {
            Storage storage = new FileStorage("http://*****:*****@"c:\data\site\demo");

            SqlConnectionStringBuilder connStrBldr = new SqlConnectionStringBuilder();

            connStrBldr.IntegratedSecurity = true;
            connStrBldr.InitialCatalog     = "TestSourceWarehouse";
            connStrBldr.DataSource         = @"(LocalDB)\v11.0";

            string connectionString = connStrBldr.ToString();

            WarehouseHelper.CreateStatisticsCatalogAsync(storage, connectionString).Wait();
        }
Beispiel #6
0
        /// <summary>
        /// Create split shipment for the first time.
        /// </summary>
        private void CreateDataSplitShipment()
        {
            // Create shipment for each lineitem for the first time to demo showcase multishipment.
            if (Cart.OrderForms.Count > 0)
            {
                var lineItems = Cart.OrderForms[0].LineItems;
                if (Cart.OrderForms[0].Shipments.Count != lineItems.Count)
                {
                    foreach (MetaObject shipment in Cart.OrderForms[0].Shipments)
                    {
                        shipment.Delete();
                    }

                    foreach (LineItem lineItem in lineItems)
                    {
                        Shipment shipment = new Shipment();
                        shipment.CreatorId = SecurityContext.Current.CurrentUserId.ToString();
                        shipment.Created   = DateTime.UtcNow;
                        shipment.AddLineItemIndex(lineItems.IndexOf(lineItem), lineItem.Quantity);
                        shipment.WarehouseCode = lineItem.WarehouseCode;

                        // For Shipping method "In store pickup"
                        IWarehouse warehouse = WarehouseHelper.GetWarehouse(lineItem.WarehouseCode);
                        if (!warehouse.IsFulfillmentCenter && warehouse.IsPickupLocation)
                        {
                            if (CartHelper.FindAddressByName(warehouse.Name) == null)
                            {
                                var address = warehouse.ContactInformation.ToOrderAddress();
                                address.Name = warehouse.Name;
                                Cart.OrderAddresses.Add(address);
                            }

                            shipment.ShippingAddressId  = warehouse.Name;
                            shipment.ShippingMethodName = ShippingManager.PickupShippingMethodName;

                            var instorepickupShippingMethod = ShippingManager.GetShippingMethods("en").ShippingMethod.ToArray().Where(m => m.Name.Equals(ShippingManager.PickupShippingMethodName)).FirstOrDefault();
                            if (instorepickupShippingMethod != null)
                            {
                                shipment.ShippingMethodId = instorepickupShippingMethod.ShippingMethodId;
                            }
                        }

                        Cart.OrderForms[0].Shipments.Add(shipment);
                    }
                }

                Cart.AcceptChanges();
            }
        }
Beispiel #7
0
        /// <summary>
        /// Handles the OrderShipment_ItemDataBound event of the lvCartItems control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void OrderShipment_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.DataItem == null)
            {
                return;
            }

            var dataItem = ((LineItem)e.Item.DataItem);
            var lit      = e.Item.FindControl("Discount") as Literal;

            if (lit != null)
            {
                var discountAmount = (dataItem.LineItemDiscountAmount + dataItem.OrderLevelDiscountAmount) / dataItem.Quantity;
                lit.Text = new Money(discountAmount, BillingCurrency).ToString();
            }

            lit = e.Item.FindControl("Quantity") as Literal;
            if (lit != null)
            {
                lit.Text = string.Format("{0:0}", dataItem.Quantity);
            }
            lit = e.Item.FindControl("ListPrice") as Literal;
            if (lit != null)
            {
                lit.Text = new Money(dataItem.ListPrice, BillingCurrency).ToString();
            }
            lit = e.Item.FindControl("YourPrice") as Literal;
            if (lit != null)
            {
                var yourPrice = (dataItem.ExtendedPrice + dataItem.OrderLevelDiscountAmount) / dataItem.Quantity;
                lit.Text = new Money(yourPrice, BillingCurrency).ToString();
            }
            lit = e.Item.FindControl("Total") as Literal;
            if (lit != null)
            {
                lit.Text = new Money(dataItem.ExtendedPrice, BillingCurrency).ToString();
            }

            lit = e.Item.FindControl("WarehouseName") as Literal;
            var warehouse = WarehouseHelper.GetWarehouse(dataItem.WarehouseCode);

            if (lit != null && warehouse != null)
            {
                lit.Text = warehouse.Name;
            }
        }
 public ActionResult DeleteInline(WarehouseModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             WarehouseHelper.Delete(model.Id.ToString());
             return(PartialView("_List", WarehouseHelper.GetWarehouses(SessionHelper.SOBId)));
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_List", WarehouseHelper.GetWarehouses(SessionHelper.SOBId)));
 }
 public ActionResult UpdateInline(WarehouseModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             model.CompanyId = AuthenticationHelper.CompanyId.Value;
             model.SOBId     = SessionHelper.SOBId;
             WarehouseHelper.Save(model);
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_List", WarehouseHelper.GetWarehouses(SessionHelper.SOBId)));
 }
Beispiel #10
0
        public ActionResult Edit(string no, DateTime date)
        {
            OrderShipmentModel orderShipment = ShipmentHelper.GetShipmentEdit(no, date);

            orderShipment.Customers = CustomerHelper.GetActiveCustomersCombo(orderShipment.DeliveryDate);
            if (orderShipment.Customers != null && orderShipment.Customers.Count() > 0)
            {
                orderShipment.CustomerId = orderShipment.CustomerId > 0 ? orderShipment.CustomerId : Convert.ToInt64(orderShipment.Customers.First().Value);
                orderShipment.Customers.Add(new SelectListItem {
                    Text = "-- Select --", Value = "0"
                });
                orderShipment.CustomerSites = CustomerHelper.GetCustomerSitesCombo(orderShipment.CustomerId);
                if (orderShipment.CustomerSites != null && orderShipment.CustomerSites.Count() > 0)
                {
                    orderShipment.CustomerSiteId = orderShipment.CustomerSiteId > 0 ? orderShipment.CustomerSiteId : Convert.ToInt64(orderShipment.CustomerSites.First().Value);
                    orderShipment.CustomerSites.Add(new SelectListItem {
                        Text = "-- Select --", Value = "0"
                    });
                }
            }

            orderShipment.Orders = OrderHelper.GetOrdersCombo();
            if (orderShipment.Orders != null && orderShipment.Orders.Count() > 0)
            {
                orderShipment.OrderId = orderShipment.OrderId > 0 ? orderShipment.OrderId : Convert.ToInt64(orderShipment.Orders.First().Value);
                orderShipment.Orders.Add(new SelectListItem {
                    Text = "-- Select --", Value = "0"
                });
            }

            orderShipment.Warehouses = WarehouseHelper.GetWarehousesCombo(SessionHelper.SOBId);
            if (orderShipment.Warehouses != null && orderShipment.Warehouses.Count() > 0)
            {
                orderShipment.WarehouseId = orderShipment.WarehouseId > 0 ? orderShipment.WarehouseId : Convert.ToInt64(orderShipment.Warehouses.First().Value);
            }

            SessionHelper.Shipment = orderShipment;

            return(View("Edit", orderShipment));
        }
        private Lazy <IEnumerable <WarehouseInventoryViewModel> > GetAllWarehouseInventory(VariationContent catalogContent)
        {
            //make sure we don't get any null reference exception when accessing Inventories.
            var inventories           = Enumerable.Empty <Inventory>();
            var allWarehouseInventory = new List <WarehouseInventoryViewModel>();

            if (catalogContent != null && catalogContent.IsAvailableInCurrentMarket())
            {
                inventories = catalogContent.GetStockPlacement(InventoryLoader);
            }

            if (inventories.Count() > 0)
            {
                foreach (Inventory inventory in inventories)
                {
                    var warehouse = WarehouseHelper.GetWarehouse(inventory.WarehouseCode);
                    if (warehouse != null && warehouse.IsActive)
                    {
                        WarehouseInventoryViewModel model = new WarehouseInventoryViewModel()
                        {
                            WarehouseCode    = warehouse.Code,
                            WarehouseName    = HttpUtility.HtmlEncode(warehouse.Name),
                            WarehouseContact = HttpUtility.HtmlEncode(string.Format("{0} - {1}", warehouse.ContactInformation.FullName,
                                                                                    warehouse.ContactInformation.Email)),
                            WarehouseAddress = HttpUtility.HtmlEncode(string.Format("{0} {1}", warehouse.ContactInformation.Line1,
                                                                                    warehouse.ContactInformation.City))
                        };
                        model.InStockLevel  = inventory.InStockQuantity;
                        model.ReservedLevel = inventory.ReservedQuantity;
                        model.IsAvailable   = (inventory.InStockQuantity - inventory.ReservedQuantity > 0);

                        allWarehouseInventory.Add(model);
                    }
                }
            }

            return(new Lazy <IEnumerable <WarehouseInventoryViewModel> >(() => allWarehouseInventory));
        }
Beispiel #12
0
        public void BindStoreInformation()
        {
            var inventories = new List <Inventory>();

            foreach (var inventory in Inventories)
            {
                var warehouse = WarehouseHelper.GetWarehouse(inventory.WarehouseCode);
                if (warehouse != null && warehouse.IsActive)
                {
                    inventories.Add(inventory);
                }
            }

            if (inventories.Any())
            {
                rptWarehouseList.DataSource = inventories;
                rptWarehouseList.DataBind();
            }
            else
            {
                Notification.Text = "No Warehouse Information";
            }
        }
 public Response CountsData(string token, [FromBody] PurchaseRequest request)
 {
     Response response = new Response();
     if (string.IsNullOrEmpty(token) || !token.Equals(_token))
     {
         response.code = "404";
         response.message = "Invild token";
     }
     else
     {
         var data = WarehouseHelper.GetCountsData(request);
         if (data == null)
         {
             response.code = "500";
             response.message = "No Data";
         }
         else
         {
             response.code = "200";
             response.content = data;
         }
     }
     return response;
 }
Beispiel #14
0
        /// <summary>
        /// Handles the lvCartItems_ItemDataBound event of the lvCartItems control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.ListViewItemEventArgs"/> instance containing the event data.</param>
        protected void lvCartItems_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType != ListViewItemType.DataItem)
            {
                return;
            }

            var lvDataItem = (ListViewDataItem)e.Item;

            if (lvDataItem == null || lvDataItem.DataItem == null)
            {
                return;
            }

            var li = (LineItem)lvDataItem.DataItem;

            //set pricing fields
            var lit = e.Item.FindControl("ListPrice") as Literal;

            if (lit != null)
            {
                lit.Text = new Money(li.PlacedPrice, _cartHelper.Cart.BillingCurrency).ToString();
            }

            var discountAmount = (li.ExtendedPrice + li.OrderLevelDiscountAmount) / li.Quantity;

            lit = e.Item.FindControl("YourPrice") as Literal;
            if (lit != null)
            {
                lit.Text = new Money(discountAmount, _cartHelper.Cart.BillingCurrency).ToString();
            }

            lit = e.Item.FindControl("ExtendedPrice") as Literal;
            var extendedPrice = li.PlacedPrice * li.Quantity - li.LineItemDiscountAmount;

            if (lit != null)
            {
                lit.Text = new Money(extendedPrice, _cartHelper.Cart.BillingCurrency).ToString();
            }

            if (discountAmount < li.PlacedPrice)
            {
                lit = e.Item.FindControl("DiscountAmount") as Literal;
                if (lit != null)
                {
                    lit.Text = new Money(li.LineItemDiscountAmount, _cartHelper.Cart.BillingCurrency).ToString();
                }

                lit = e.Item.FindControl("itemDiscounts") as Literal;
                if (lit != null)
                {
                    var itemDiscounts = string.Empty;

                    if (_promotionResult != null && _promotionResult.PromotionRecords.Count > 0)
                    {
                        foreach (var record in _promotionResult.PromotionRecords)
                        {
                            var recordItem = record.AffectedEntriesSet.Entries.FirstOrDefault(item => item.CatalogEntryCode == li.CatalogEntryId);
                            if ((recordItem != null) && (recordItem.Quantity > 0))
                            {
                                var promotionLanguage     = record.PromotionItem.DataRow.GetPromotionLanguageRows().FirstOrDefault().LanguageCode;
                                var defaultMarketLanguage = _currentMarket.DefaultLanguage.ToString();
                                var discountAmountLit     = record.PromotionReward.AmountType.Equals(Constants.AmountTypeValueBased) ? new Money(record.PromotionReward.AmountOff, _cartHelper.Cart.BillingCurrency).ToString() :
                                                            record.PromotionReward.AmountOff.ToString() + "%";

                                itemDiscounts += (promotionLanguage == defaultMarketLanguage) ?
                                                 (String.Format("<strong>{0}</strong><span> | Value: </span>{1}<br />", record.PromotionItem.DataRow.GetPromotionLanguageRows().FirstOrDefault().DisplayName, discountAmountLit)) :
                                                 (String.Format("<strong>{0}</strong><span> | Value: </span>{1}<br />", record.PromotionItem.DataRow.Name, discountAmountLit));
                            }
                        }
                    }

                    lit.Text = itemDiscounts;
                }
            }
            else
            {
                var div = e.Item.FindControl("divItemLevelDiscount");
                if (div != null)
                {
                    div.Visible = false;
                }
            }

            var linkButton = e.Item.FindControl("MoveWishList") as LinkButton;

            if (linkButton != null)
            {
                if (lvDataItem.DataItem != null)
                {
                    linkButton.Visible = !((LineItem)lvDataItem.DataItem).CatalogEntryId.StartsWith("@");
                }
            }

            lit = e.Item.FindControl("WarehouseName") as Literal;
            var warehouse = WarehouseHelper.GetWarehouse(li.WarehouseCode);

            if (lit != null && warehouse != null)
            {
                lit.Text = HttpUtility.HtmlEncode(warehouse.Name);
            }
        }
 public ActionResult GetWarehouses()
 {
     return(PartialView("_List", WarehouseHelper.GetWarehouses(SessionHelper.SOBId)));
 }