public SpecificSubjectResponse Map(SpecificSubject source) { if (source == null) { return(null); } return(new SpecificSubjectResponse { Id = source.Id, Name = source.Name, GeneralSubjectId = source.GeneralSubjectId, }); }
public async Task <SpecificSubject> GetSpecSubjectByIdAsync(int id) { var result = await _dbContext.Subjects.FirstOrDefaultAsync(s => s.Id == id); var response = new SpecificSubject() { Id = result.Id, Credit = result.Credit, Description = result.Description, Title = result.Title, Creator = (await _dbContext.Users.FirstOrDefaultAsync(x => x.Id == result.UserId)).Name, CreationTime = result.CreationTime, Courses = (await _dbContext.Courses.Where(x => x.SubjectId == id).ToListAsync()) }; return(response); }
public async Task OnGetAsync(int id, [FromServices] SubjectService subjectService) { SpecificSubject = await subjectService.GetSpecSubjectByIdAsync(id); }