Пример #1
0
 public static FollowUpList ConvertFollowUpListToDAL(FollowUpListDTO f)
 {
     return(new FollowUpList
     {
         Amount = f.Amount,
         FollowUpListId = f.FollowUpListId,
         FrequencyId = f.FrequencyId,
         ProductId = f.ProductId,
         AccountId = f.AccountId
     });
 }
Пример #2
0
 /// <summary>
 /// הוספת מוצרים לרשימת המוצרים למעקב על פי בחירת המשתמש לחשבון
 /// </summary>
 /// <param name="idSelectedProducts"></param>
 /// <param name="idAccount"></param>
 public static void AddFollowUp(int[] idSelectedProducts, int idAccount)
 {
     using (ProjectDBEntities db = new ProjectDBEntities())
     {
         foreach (int item in idSelectedProducts)
         {
             FollowUpListDTO f = new FollowUpListDTO();
             if (!db.FollowUpLists.Any(a => a.AccountId == idAccount && a.ProductId == item))
             {
                 f.ProductId = item;
                 f.AccountId = idAccount;
                 db.FollowUpLists.Add(CONVERTERS.FollowUpListConverter.ConvertFollowUpListToDAL(f));
             }
         }
         db.SaveChanges();
         var removedItems = db.FollowUpLists.Where(p => !idSelectedProducts.Any(p2 => p2 == p.ProductId) && p.AccountId == idAccount).ToList();
         db.FollowUpLists.RemoveRange(removedItems);
         db.SaveChanges();
     }
 }