public Transaction GetTransactionById(int id) { var transaction = db.Transactions.Find(id); if (transaction != null) { db.Entry(transaction).Reference(t => t.Tool).Load(); db.Entry(transaction).Reference(t => t.PersonBuyer).Load(); db.Entry(transaction).Reference(t => t.PersonSeller).Load(); } return(transaction); }
public bool DeleteTool(int id) { try { var tool = new Tool { Id = id }; db.Tools.Attach(tool); db.Entry(tool).State = EntityState.Deleted; db.SaveChanges(); } catch (Exception) { return(false); } return(true); }
public bool DeletePerson(int id) { try { var person = new Person { Id = id }; db.Persons.Attach(person); db.Entry(person).State = EntityState.Deleted; db.SaveChanges(); } catch (Exception) { return(false); } return(true); }