예제 #1
0
 public static bool addLending(LENDING l)
 {
     using (DAL.Charity_DBEntities db = new DAL.Charity_DBEntities())
     {
         db.LENDINGS.Add(Converters.LendingConverter.convertToDAL(l));
         try
         {
             db.SaveChanges();
             return(true);
         }
         catch (DbEntityValidationException ex)
         {
             foreach (var entityValidationErrors in ex.EntityValidationErrors)
             {
                 foreach (var validationError in entityValidationErrors.ValidationErrors)
                 {
                     System.Diagnostics.Debug.WriteLine(
                         "Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                 }
             }
             System.Diagnostics.Debug.WriteLine("no");
             return(false);
         }
     }
 }
예제 #2
0
 public static bool deleteLending(LENDING l)
 {
     using (DAL.Charity_DBEntities db = new DAL.Charity_DBEntities())
     {
         DAL.LENDINGS l1 = db.LENDINGS.SingleOrDefault(le => le.ProductCode == l.ProductCode && le.LendingDate == l.LendingDate);
         db.LENDINGS.Remove(l1);
         try
         {
             db.SaveChanges();
             return(true);
         }
         catch (DbEntityValidationException ex)
         {
             foreach (var entityValidationErrors in ex.EntityValidationErrors)
             {
                 foreach (var validationError in entityValidationErrors.ValidationErrors)
                 {
                     System.Diagnostics.Debug.WriteLine(
                         "Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                 }
             }
             System.Diagnostics.Debug.WriteLine("no");
             return(false);
         }
     }
 }
예제 #3
0
        }//פונקציה שמקבלת מוצר ומחזירה את רשימת ההלואות שלו

        public static bool SetLending(LENDING l)
        {
            using (DAL.Charity_DBEntities db = new DAL.Charity_DBEntities())
            {
                db.LENDINGS.FirstOrDefault(l1 => l1.LendingCode == l.LendingCode).Comment = l.Comment;
                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (DbEntityValidationException ex)
                {
                    foreach (var entityValidationErrors in ex.EntityValidationErrors)
                    {
                        foreach (var validationError in entityValidationErrors.ValidationErrors)
                        {
                            System.Diagnostics.Debug.WriteLine(
                                "Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                        }
                    }
                    System.Diagnostics.Debug.WriteLine("no");
                    return(false);
                }
            }
        }