예제 #1
0
        public void CalcPrice()
        {
            Price = BasePrice;
            List <Good> goods    = GetPath();
            List <int>  ids      = goods.Select(s => s.Id).ToList();
            Sale        bestSale = ModelService.GetAllSaleGoodMaps().Where(w => ids.Contains(w.GoodId)).Select(s => s.Sale).Where(w => w.FinishDate > DateTime.Now).OrderByDescending(o => o.PercentSale).FirstOrDefault();

            if (bestSale != null)
            {
                Price = BasePrice * (100 - bestSale.PercentSale) / 100;
            }
        }
예제 #2
0
        public List <Good> GetPath()
        {
            List <Good> goods = new List <Good>();

            goods.Add(this);
            Good temp = this;

            while (true)
            {
                if (temp.ParentId == null)
                {
                    break;
                }
                else
                {
                    temp = ModelService.GetGoodById((int)temp.ParentId);
                    goods.Add(temp);
                }
            }

            return(goods);
        }