Ejemplo n.º 1
0
 public Department GetDepartment(int id)
 {
     using (var context = new WorkersDbContext(_options))
     {
         return(context.Departments.FirstOrDefault(x => x.Id == id));
     }
 }
Ejemplo n.º 2
0
 public IEnumerable <Language> GetLanguages()
 {
     using (var context = new WorkersDbContext(_options))
     {
         return(context.Languages);
     }
 }
Ejemplo n.º 3
0
 public IEnumerable <Department> GetDepartments()
 {
     using (var context = new WorkersDbContext(_options))
     {
         return(context.Departments);
     }
 }
Ejemplo n.º 4
0
 public Language GetLanguage(int id)
 {
     using (var context = new WorkersDbContext(_options))
     {
         return(context.Languages.FirstOrDefault(x => x.Id == id));
     }
 }
Ejemplo n.º 5
0
 public void AddLanguage(Language language)
 {
     using (var context = new WorkersDbContext(_options))
     {
         context.Languages.Add((Language)language);
         context.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 public void AddWorker(Worker worker)
 {
     using (var context = new WorkersDbContext(_options))
     {
         context.Workers.Add((Worker)worker);
         context.SaveChanges();
     }
 }
Ejemplo n.º 7
0
 public IEnumerable <Worker> GetWorkers()
 {
     using (var context = new WorkersDbContext(_options))
     {
         return(context.Workers.Include(x => x.Language)
                .Include(x => x.Department));
     }
 }
Ejemplo n.º 8
0
 public void AddDepartment(Department department)
 {
     using (var context = new WorkersDbContext(_options))
     {
         context.Departments.Add((Department)department);
         context.SaveChanges();
     }
 }
Ejemplo n.º 9
0
 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());
     }
 }
Ejemplo n.º 10
0
 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);
     }
 }