public async Task <ActionResult <Department> > GetDepartment([FromServices] testsContext context, string name)
        {
            name = name?.ToLower();
            var department = await context.Department.AsNoTracking()
                             .Include(it => it.Employee).FirstOrDefaultAsync(it => it.Name.ToLower() == name);

            //var department = await _context.Department.FirstOrDefaultAsync(it => it.Iddepartment == id);
            if (department == null)
            {
                return(NotFound());
            }
            foreach (var emp in department.Employee)
            {
                emp.IddepartmentNavigation = null;
            }
            return(department);
        }
Ejemplo n.º 2
0
 public DB_EmployeesController(testsContext context)
 {
     _context = context;
 }
Ejemplo n.º 3
0
 public DepartmentRepository(testsContext context)
 {
     _context = context;
 }
Ejemplo n.º 4
0
 public DepartmentsController(testsContext context)
 {
     _context = context;
 }
 public DepartmentsController(testsContext context)
 {
     context.Database.EnsureCreated();
     _context = context;
 }