///<inheritdoc/> public async Task UpdateTeacher(Teacher teacher) { TeacherEntity teacherEntity = await _websiteDbContext.Teachers.FindAsync(teacher.Id); _websiteDbContext.Teachers.Update(TeacherConverter.CopyData(teacher, teacherEntity)); await _websiteDbContext.SaveChangesAsync(); }
///<inheritdoc/> public async Task <Teacher> GetHead(Guid departmentId) { TeacherEntity teacherEntity = await _websiteDbContext.DepartmentTeacherRelations.Where(x => x.DepartmentId == departmentId) .Where(x => x.IsDepartmentHead == true) .Include(x => x.Teacher) .Select(x => x.Teacher) .FirstOrDefaultAsync(); return(TeacherConverter.Convert(teacherEntity)); }
///<inheritdoc/> public async Task <IEnumerable <Teacher> > GetTeachers(Guid departmentId, TeachingType?teachingType) { IQueryable <DepartmentTeacherRelationEntity> query; query = _websiteDbContext.DepartmentTeacherRelations.Where(x => x.DepartmentId == departmentId); if (teachingType.HasValue) { query = query.Where(x => x.TeachingType == teachingType.Value); } return((await query.Select(x => x.Teacher).ToArrayAsync()).Select(x => TeacherConverter.Convert(x))); }
public async Task <IActionResult> Put([FromBody] Teacher teacher) { if (teacher == null) { return(BadRequest()); } await TeacherRepository.UpdateAsync(TeacherConverter.Convert(teacher)); return(new OkObjectResult(teacher)); }
///<inheritdoc/> public async Task <Teacher> GetTeacher(Guid id) { return(TeacherConverter.Convert(await _websiteDbContext.Teachers.FindAsync(id))); }
///<inheritdoc/> public Task CreateTeacher(Teacher teacher) { _websiteDbContext.Teachers.Add(TeacherConverter.CopyData(teacher)); return(_websiteDbContext.SaveChangesAsync()); }
public async Task <IEnumerable <TeacherResponse> > GetAdminTeachers() { var teachers = await TeacherRepository.GetEntityListAsync(); return(teachers.Select(x => TeacherConverter.ConvertTo(x))); }