Example #1
0
 public static void AddProductsToList(BuyListDTO buyList)
 {
     using (ProjectDBEntities db = new ProjectDBEntities())
     {//משנה את פרטי המוצר לפי הקניה ושולח לעדכון התדירות של קנייתו
         foreach (var pr in buyList.Products)
         {
             var prod = db.ProductToLists.FirstOrDefault(p => p.ListId == buyList.ListId && p.ProductId == pr.ProductId);
             prod.BuyerId   = buyList.UserId;
             prod.DateOfBuy = DateTime.Now;
             prod.Amount    = pr.Amount;
             db.SaveChanges();
             var follow = db.FollowUpLists.Include(p => p.Frequency).FirstOrDefault(f => f.ProductId == prod.ProductId);
             if (follow != null)
             {
                 BL.FollowUpBL.SetFrequency(follow);
             }
         }
     }
 }
Example #2
0
 public IHttpActionResult UpdateBuyList(BuyListDTO buyList)
 {
     BL.ProductToListBL.AddProductsToList(buyList);
     return(Ok(true));
 }