Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }