public void SelectActualPriceList()
        {
            var today = DateTime.Today;
            var expected = new AnalyzePriceList { BeginDate = today };
            var list = new List<AnalyzePriceList>
            {
                new AnalyzePriceList {  BeginDate = today.AddDays(-1) },
                expected,
                new AnalyzePriceList {  BeginDate = today.AddDays(1) },
            };

            Assert.AreSame(expected, AnalyzePriceList.SelectActualPriceList(list));
        }
Пример #2
0
 public List<AnalyzePrice> UploadPrices(long priceListId, List<AnalyzePrice> prices)
 {
     using (var database = new Core.Entity.SeedsEntities())
     {
         var entity = database.AnalyzePriceList.Single(pl => pl.ID == priceListId);
         if (!entity.Prices.IsLoaded)
         {
             entity.Prices.Load();
         }
         entity.Prices.Clear();
         foreach (var price in prices)
         {
             entity.Prices.Add(price.ToEntity(database));
         }
         database.SaveChanges();
         var priceList = new AnalyzePriceList(database.AnalyzePriceList.Execute(MergeOption.NoTracking).First(pl => pl.ID == priceListId), true);
         Cache.Instance.PriceLists[priceListId] = priceList;
         return priceList.Prices.ToList();
     }
 }
Пример #3
0
 public AnalyzePriceList CreatePriceList(AnalyzePriceList priceList)
 {
     using (var database = new Core.Entity.SeedsEntities())
     {
         var entity = priceList.ToEntity(database);
         database.AddToAnalyzePriceList(entity);
         database.SaveChanges();
         var result = new AnalyzePriceList(database.AnalyzePriceList.Execute(MergeOption.NoTracking).Single(pl => pl.ID == entity.ID), true);
         Cache.Instance.PriceLists[result.ID] = result;
         return result;
     }
 }