// GetTeacher by id public async Task <TeacherViewModel> GetTeacher(string teacherId) { var teacher = await _teacherRepository.GetTeacher(_hashids.Decode(teacherId)); return(new TeacherViewModel() { TeacherId = teacherId.ToString(), TeacherFirstName = teacher.FirstName, TeacherLastName = teacher.LastName, TeacherFatherName = teacher.FatherName }); }
public List <StudentViewModel> GetStudents(string schoolClassId) { var students = _schoolClassRepository.GetStudentsList(_hashidsService.Decode(schoolClassId)); return(students.Select(s => new StudentViewModel { StudentId = _hashidsService.Encode(s.Id), StudentFirstName = s.FirstName, StudentLastName = s.LastName, SchoolClassId = _hashidsService.Encode(s.SchoolClassId) }).ToList()); }
public static void RegisterMappings() { Mapper.Initialize(cfg => { cfg.CreateMap <SchoolClass, SchoolClassViewModel>() .ForMember(dest => dest.SchoolClassName, opt => opt.MapFrom(source => source.Name)); cfg.CreateMap <Mark, MarkViewModel>() .ForMember(dest => dest.StudentId, opt => opt.MapFrom(src => _hashidService.Encode(src.StudentId))) .ForMember(dest => dest.SubjectId, opt => opt.MapFrom(src => _hashidService.Encode(src.SubjectId))); cfg.CreateMap <MarkPostViewModel, Mark>() .ForMember(dest => dest.StudentId, opt => opt.MapFrom(src => _hashidService.Decode(src.StudentId))) .ForMember(dest => dest.SubjectId, opt => opt.MapFrom(src => _hashidService.Decode(src.SubjectId))); }); }
//Get list of entries SchoolClassSubjects by Teacher Id //Получить список сущностей записей из таблицы SchoolClassSubject по Teacher Id public async Task <List <SchoolClassSubject> > TeachersSchoolClassesAndSubjects(string teacherNumber) { return(await _teacherSclClsSubjRepository.GetSchoolClassSubjectsByTeacherId(_hashidsService.Decode(teacherNumber))); }
//Checking entry between SchoolClass and Subject in SchoolClassSubject table //Проверка есть ли запись в таблице SchoolClass-И-Subject public int CheckEntryBetweenSchoolClassAndSubjectInDataBase(string schoolClassNumber, string SubjectNumber) { int entryId = _schoolClassSubjectRepository.CheckEntryBetweenSchoolClassAndSubjectInDataBase(_hashidService.Decode(schoolClassNumber), _hashidService.Decode(SubjectNumber)); if (entryId != 0) { return(entryId); } else { return(0); } }