public Department GetDepartment(int id) { using (var context = new WorkersDbContext(_options)) { return(context.Departments.FirstOrDefault(x => x.Id == id)); } }
public IEnumerable <Language> GetLanguages() { using (var context = new WorkersDbContext(_options)) { return(context.Languages); } }
public IEnumerable <Department> GetDepartments() { using (var context = new WorkersDbContext(_options)) { return(context.Departments); } }
public Language GetLanguage(int id) { using (var context = new WorkersDbContext(_options)) { return(context.Languages.FirstOrDefault(x => x.Id == id)); } }
public void AddLanguage(Language language) { using (var context = new WorkersDbContext(_options)) { context.Languages.Add((Language)language); context.SaveChanges(); } }
public void AddWorker(Worker worker) { using (var context = new WorkersDbContext(_options)) { context.Workers.Add((Worker)worker); context.SaveChanges(); } }
public IEnumerable <Worker> GetWorkers() { using (var context = new WorkersDbContext(_options)) { return(context.Workers.Include(x => x.Language) .Include(x => x.Department)); } }
public void AddDepartment(Department department) { using (var context = new WorkersDbContext(_options)) { context.Departments.Add((Department)department); context.SaveChanges(); } }
public Worker GetWorker(int id) { using (var context = new WorkersDbContext(_options)) { return(context.Workers .Where(x => x.Id == id) .Include(x => x.Language) .Include(x => x.Department) .FirstOrDefault()); } }
public bool RemoveWorker(int id) { using (var context = new WorkersDbContext(_options)) { var worker = context.Workers .FirstOrDefault(x => x.Id == id); if (worker == null) { return(false); } context.Workers.Remove(worker); context.SaveChanges(); return(true); } }