public List <Fornecedor> List() { using (var db = new ServicosContext()) { return(db.Fornecedor.ToList()); } }
public void Update(Fornecedor fornecedor) { try { using (var db = new ServicosContext()) { var context = new ValidationContext(fornecedor, serviceProvider: null, items: null); var results = new List <ValidationResult>(); if (Validator.TryValidateObject(fornecedor, context, results, true)) { db.Entry(fornecedor).State = EntityState.Modified; db.SaveChanges(); return; } string erros = string.Empty; foreach (var item in results) { erros += (string.IsNullOrEmpty(erros) ? "" : "\n") + item.ErrorMessage; } throw new DbEntityValidationException(erros); } } catch (Exception) { throw; } }
public Servico Get(int id) { using (var db = new ServicosContext()) { return(db.Servico.FirstOrDefault(x => x.Id == id)); } }
public Fornecedor Get(int id) { using (var db = new ServicosContext()) { return(db.Fornecedor.FirstOrDefault(x => x.Id == id)); } }
public void CleanUp() { using (var db = new ServicosContext()) { db.Database.ExecuteSqlCommand("DELETE from Fornecedor;"); db.Database.ExecuteSqlCommand("DBCC CHECKIDENT('Fornecedor', RESEED, 0);"); } }
public List <Servico> List() { using (var db = new ServicosContext()) { return(db.Servico .Include(s => s.Cliente) .Include(s => s.Fornecedor) .ToList()); } }
public void Delete(int id) { using (var db = new ServicosContext()) { var fornecedor = db.Fornecedor.FirstOrDefault(x => x.Id == id); if (fornecedor != null) { db.Fornecedor.Remove(fornecedor); db.SaveChanges(); } else { throw new DbEntityValidationException(string.Format("Não foi possível encontrar o fornecedor com código {0}", id)); } } }
public void AddRange(List <Fornecedor> fornecedores) { using (var db = new ServicosContext()) { var context = new ValidationContext(fornecedores, serviceProvider: null, items: null); var results = new List <ValidationResult>(); if (Validator.TryValidateObject(fornecedores, context, results, true)) { db.Fornecedor.AddRange(fornecedores); db.SaveChanges(); return; } string erros = string.Empty; foreach (var item in results) { erros += (string.IsNullOrEmpty(erros) ? "" : "\n") + item.ErrorMessage; } throw new DbEntityValidationException(erros); } }
public AbstractEditableEntityRepository(ServicosContext dbContext) : base(dbContext) { }
public PessoaRepo() { _contexto = new ServicosContext(); }
public OrdemServicoRepo() { _contexto = new ServicosContext(); }
public AbstractEntityRepository(ServicosContext dbContext) { _dbContext = dbContext; }