public dynamic Add() { if (this.id > 0) { return(false); } WpfEntities db = new WpfEntities(); try { db.Customers.Add(this); db.SaveChanges(); return(this.id); } catch (Exception Exception) { //JDR: Exception can be logged here Console.WriteLine("***EROR_CATCH*** - An error occurred: '{0}'", Exception); return(false); } finally { db.Dispose(); } }
public static dynamic GetByID(int id) { WpfEntities db = new WpfEntities(); Customer Customer = db.Customers.Find(id); db.Dispose(); if (Customer == null) { return(null); } return(Customer); }
public bool Save() { WpfEntities db = new WpfEntities(); try { db.Entry(this).State = EntityState.Modified; db.SaveChanges(); return(true); } catch (Exception Exception) { //JDR: Exception can be logged here Console.WriteLine("***EROR_CATCH*** - An error occurred: '{0}'", Exception); return(false); } finally { db.Dispose(); } }