public async Task <TeacherModel> GetCreateTeacher(IDepartamentRepository repository) { var departaments = await repository.ToListAsync(); TeacherModel model = new TeacherModel { Departaments = departaments }; return(model.Clone() as TeacherModel); }
public async Task <TeacherModel> GetEditTeacher(int?id, IDepartamentRepository departamentRepository) { if (id == null) { return(null); } var teacher = await AllItems.Include(d => d.Departament).FirstOrDefaultAsync(z => z.Id == id); if (teacher == null) { return(null); } TeacherModel model = new TeacherModel { Id = teacher.Id, FirstName = teacher.FirstName, LastName = teacher.LastName, Departament = teacher.Departament, Departaments = await departamentRepository.ToListAsync() }; return(model.Clone() as TeacherModel); }