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); } } }
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); } } }
}//פונקציה שמקבלת מוצר ומחזירה את רשימת ההלואות שלו 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); } } }