public List <ItemMasterDataWithUnitprice> GetMasterDataWithUnitprice()
        {
            List <ItemMasterDataWithUnitprice> itemMasterDataWithUnitprices = new List <ItemMasterDataWithUnitprice>();
            ItemMasterDataWithUnitprice        itemMasterDataWithUnitprice  = new ItemMasterDataWithUnitprice();

            itemMasterDataWithUnitprice.SKUNAME   = "A";
            itemMasterDataWithUnitprice.UnitPrice = 50;
            itemMasterDataWithUnitprices.Add(itemMasterDataWithUnitprice);


            itemMasterDataWithUnitprice           = new ItemMasterDataWithUnitprice();
            itemMasterDataWithUnitprice.SKUNAME   = "B";
            itemMasterDataWithUnitprice.UnitPrice = 30;
            itemMasterDataWithUnitprices.Add(itemMasterDataWithUnitprice);

            itemMasterDataWithUnitprice           = new ItemMasterDataWithUnitprice();
            itemMasterDataWithUnitprice.SKUNAME   = "C";
            itemMasterDataWithUnitprice.UnitPrice = 20;
            itemMasterDataWithUnitprices.Add(itemMasterDataWithUnitprice);

            itemMasterDataWithUnitprice           = new ItemMasterDataWithUnitprice();
            itemMasterDataWithUnitprice.SKUNAME   = "D";
            itemMasterDataWithUnitprice.UnitPrice = 15;
            itemMasterDataWithUnitprices.Add(itemMasterDataWithUnitprice);


            return(itemMasterDataWithUnitprices);
        }
        private long CalculateIndividualTotal(List <Items> items, List <Promotion> promotions)
        {
            #region Individual Dynamic
            long total = 0;
            //Get Master Data And Promotion from Cache or DB
            var MasterData = _calculationDAO.GetMasterDataWithUnitprice();

            foreach (var item in items)
            {
                var PromotionData = promotions.Where(name => name.SKUNAME.Equals(item.SKUName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

                ItemMasterDataWithUnitprice data = MasterData.Where(a => a.SKUNAME.Equals(item.SKUName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

                int count = 0;
                if (!string.IsNullOrWhiteSpace(PromotionData.SKUNAME))
                {
                    while (item.Quantity >= PromotionData.PromotionQuantity)
                    {
                        count++;
                        item.Quantity = item.Quantity - PromotionData.PromotionQuantity;
                    }
                    if (count > 0)
                    {
                        total = total + (count * PromotionData.PromotionPrice);
                    }

                    if (item.Quantity > 0)
                    {
                        total = total + (item.Quantity * data.UnitPrice);
                    }
                }
                else
                {
                    total = total + (item.Quantity * data.UnitPrice);
                }
            }
            #endregion

            return(total);
        }
        private long CalCulateCombineTotal(List <Items> items, List <Promotion> promotions, List <string> combinePromotion)
        {
            long total = 0;

            List <Items> Combineditems             = new List <Items>();
            ItemMasterDataWithUnitprice Firstdata  = new ItemMasterDataWithUnitprice();
            ItemMasterDataWithUnitprice Seconddata = new ItemMasterDataWithUnitprice();


            foreach (var item in combinePromotion)
            {
                List <string> SKUName         = item.Split(',').ToList();
                var           ActivePromotion = promotions.Where(a => a.SKUNAME.Equals(item, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

                foreach (string names in SKUName)
                {
                    var matchitem = items.Where(item1 => item1.SKUName.Equals(names, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                    if (matchitem != null)
                    {
                        Combineditems.Add(matchitem);
                    }
                }

                var MasterData = _calculationDAO.GetMasterDataWithUnitprice();
                if (Combineditems.Count() > 0)
                {
                    var SKUCDetails = Combineditems.Where(itm => itm.SKUName.Equals("C", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                    if (SKUCDetails != null)
                    {
                        Firstdata = MasterData.Where(a => a.SKUNAME.Equals(SKUCDetails.SKUName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                    }

                    var SKUDDetails = items.Where(itm => itm.SKUName.Equals("D", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                    if (SKUDDetails != null)
                    {
                        Seconddata = MasterData.Where(a => a.SKUNAME.Equals(SKUDDetails.SKUName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                    }


                    if (ActivePromotion != null && !string.IsNullOrWhiteSpace(Firstdata.SKUNAME) && !string.IsNullOrWhiteSpace(Seconddata.SKUNAME))
                    {
                        if (SKUCDetails.Quantity > SKUDDetails.Quantity)
                        {
                            long diffrence = SKUCDetails.Quantity - SKUDDetails.Quantity;
                            total = total + (SKUDDetails.Quantity * ActivePromotion.PromotionPrice);

                            total = total + (diffrence * Firstdata.UnitPrice);
                        }
                        else if (SKUCDetails.Quantity < SKUDDetails.Quantity)
                        {
                            long diffrence = SKUDDetails.Quantity - SKUCDetails.Quantity;
                            total = total + (SKUCDetails.Quantity * ActivePromotion.PromotionPrice);

                            total = total + (diffrence * Seconddata.UnitPrice);
                        }
                        else
                        {
                            total = total + (SKUDDetails.Quantity * ActivePromotion.PromotionPrice);
                        }
                    }

                    else
                    {
                        if (SKUCDetails != null)
                        {
                            total = total + (SKUCDetails.Quantity * Firstdata.UnitPrice);
                        }

                        if (SKUDDetails != null)
                        {
                            total = total + (SKUDDetails.Quantity * Seconddata.UnitPrice);
                        }
                    }
                }
            }

            return(total);
        }