コード例 #1
0
        public static List <ShoppingCartItemReportModel> ToReportModel(this List <ShoppingCartItem> items)
        {
            List <ShoppingCartItemReportModel> newList = new List <ShoppingCartItemReportModel>();

            foreach (ShoppingCartItem i in items)
            {
                ShoppingCartItemReportModel n = new ShoppingCartItemReportModel();

                n.ItemNumber = i.ItemNumber;
                n.Name       = i.Name;
                n.Brand      = i.Brand;
                n.Category   = i.ItemClass;
                n.PackSize   = i.PackSize;
                if (i.Notes != null)
                {
                    n.Notes = i.Notes;
                }
                n.Label        = i.Label;
                n.ParLevel     = i.ParLevel;
                n.Quantity     = i.Quantity;
                n.Each         = i.Each;
                n.CasePrice    = i.CasePrice.ToDouble().Value;
                n.PackagePrice = i.PackagePrice.ToDouble().Value;

                n.ExtPrice = PricingHelper.GetPrice((int)i.Quantity, i.CasePriceNumeric, i.PackagePriceNumeric,
                                                    i.Each, i.CatchWeight, i.AverageWeight,
                                                    i.Pack.ToInt(1));

                newList.Add(n);
            }


            return(newList);
        }
コード例 #2
0
ファイル: ListExtensions.cs プロジェクト: tlwilliams88/Entree
        /// <summary>
        /// Converts listitems to ShoppingCartItemReportModel
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static List <ShoppingCartItemReportModel> ToShoppingCartItemReportList(this PagedListModel list)
        {
            List <ShoppingCartItemReportModel> items = new List <ShoppingCartItemReportModel>();

            if (list.Items != null &&
                list.Items.Results != null)
            {
                foreach (ListItemModel i in list.Items.Results)
                {
                    ShoppingCartItemReportModel item = new ShoppingCartItemReportModel();

                    item.ItemNumber = i.ItemNumber;
                    item.Name       = i.Name;
                    item.Brand      = i.BrandExtendedDescription;
                    item.Category   = i.ItemClass;
                    item.PackSize   = i.PackSize;
                    if (i.Notes != null)
                    {
                        item.Notes = i.Notes;
                    }
                    item.Label        = i.Label;
                    item.ParLevel     = i.ParLevel;
                    item.Quantity     = i.Quantity;
                    item.Each         = i.Each;
                    item.CasePrice    = i.CasePrice.ToDouble().Value;
                    item.PackagePrice = i.PackagePrice.ToDouble().Value;


                    item.ExtPrice = PricingHelper.GetPrice((int)i.Quantity, i.CasePriceNumeric, i.PackagePriceNumeric,
                                                           (i.Each ?? false), i.CatchWeight, i.AverageWeight,
                                                           i.Pack.ToInt(1));

                    items.Add(item);
                }
            }

            return(items);
        }