public async Task <LecturalDTO> AddLecturalAsync(LecturalDTO lecturalDTO) { MilitaryRank militaryRank = await _context.MilitaryRank.Where(c => c.name == lecturalDTO.MilitaryRank).FirstOrDefaultAsync(); Position position = await _context.Position.Where(c => c.name == lecturalDTO.Position).FirstOrDefaultAsync(); AcademicDegree academicDegree = await _context.AcademicDegree.Where(c => c.name == lecturalDTO.AcademicDegree).FirstOrDefaultAsync(); AcademicTitle academicTitle = await _context.AcademicTitle.Where(c => c.name == lecturalDTO.AcademicTitle).FirstOrDefaultAsync(); Lectural newLecture = new Lectural(lecturalDTO, militaryRank, position, academicDegree, academicTitle); try { _context.Lectural.Add(newLecture); await _context.SaveChangesAsync(); return(lecturalDTO); } catch (DbUpdateConcurrencyException) { if (!LecturalExists(lecturalDTO.id)) { return(null); } else { throw; } } }
internal LecturalMininfo(Lectural lecturalDB) { id = lecturalDB.id; firstName = lecturalDB.firstName; middleName = lecturalDB.middleName; lastName = lecturalDB.lastName; pathPhotoSmall = lecturalDB.pathPhotoSmall; pathPhotoBig = lecturalDB.pathPhotoBig; if (lecturalDB.MilitaryRank == null) { MilitaryRank = "none"; } else { MilitaryRank = lecturalDB.MilitaryRank.name; } if (lecturalDB.Position == null) { Position = "none"; } else { Position = lecturalDB.Position.name; } }
private async Task <LessonDB> ModifyLesson(LessonDB lessonDB, LessonDTO lessonDTO) { lessonDB.id = lessonDTO.id; lessonDB.countHours = lessonDTO.countHours; lessonDB.name = lessonDTO.name; lessonDB.pathToMaterials = lessonDTO.pathToMaterials; lessonDB.sectionName = lessonDTO.sectionName; lessonDB.themeName = lessonDTO.themeName; if (lessonDB.Discipline != null) { if (lessonDB.Discipline.id != lessonDTO.disciplineId) { DisciplineDB disciplineDB = await _context.Discipline.Where(c => c.id == lessonDTO.disciplineId).FirstOrDefaultAsync(); lessonDB.Discipline = disciplineDB; } } else { DisciplineDB disciplineDB = await _context.Discipline.Where(c => c.id == lessonDTO.disciplineId).FirstOrDefaultAsync(); lessonDB.Discipline = disciplineDB; } if (lessonDB.Lectural != null) { if (lessonDB.Lectural.id != lessonDTO.lecturalId) { Lectural lectural = await _context.Lectural.Where(c => c.id == lessonDTO.lecturalId).FirstOrDefaultAsync(); lessonDB.Lectural = lectural; } } else { Lectural lectural = await _context.Lectural.Where(c => c.id == lessonDTO.lecturalId).FirstOrDefaultAsync(); lessonDB.Lectural = lectural; } if (lessonDB.LessonTypeDB != null) { if (lessonDB.LessonTypeDB.nameOfType != lessonDTO.lessonType) { LessonTypeDB type = _context.LessonType.Where(c => c.nameOfType == lessonDTO.lessonType).FirstOrDefault(); lessonDB.LessonTypeDB = type; } } else { LessonTypeDB type = _context.LessonType.Where(c => c.nameOfType == lessonDTO.lessonType).FirstOrDefault(); lessonDB.LessonTypeDB = type; } return(lessonDB); }
internal LecturalDTO(Lectural lecturalDB) { id = lecturalDB.id; firstName = lecturalDB.firstName; middleName = lecturalDB.middleName; lastName = lecturalDB.lastName; birthDay = lecturalDB.birthDay; pathPhotoSmall = lecturalDB.pathPhotoSmall; pathPhotoBig = lecturalDB.pathPhotoBig; serialAndNumderMilitaryDocs = lecturalDB.serialAndNumderMilitaryDocs; serialAndNumderCivilyDocs = lecturalDB.serialAndNumderCivilyDocs; dateOfStartService = lecturalDB.dateOfStartService; isMarried = lecturalDB.isMarried; countOfChildren = lecturalDB.countOfChildren; info = lecturalDB.info; dateOfIssue = lecturalDB.dateOfIssue; dateOfExpiry = lecturalDB.dateOfExpiry; whoGetPassport = lecturalDB.whoGetPassport; nameOFVoinkom = lecturalDB.nameOFVoinkom; FormSec = lecturalDB.FormSec; DateFormSec = lecturalDB.DateFormSec; if (lecturalDB.MilitaryRank == null) { MilitaryRank = "none"; } else { MilitaryRank = lecturalDB.MilitaryRank.name; } if (lecturalDB.Position == null) { Position = "none"; } else { Position = lecturalDB.Position.name; } if (lecturalDB.AcademicTitle == null) { AcademicTitle = "none"; } else { AcademicTitle = lecturalDB.AcademicTitle.name; } if (lecturalDB.AcademicDegree == null) { AcademicDegree = "none"; } else { AcademicDegree = lecturalDB.AcademicDegree.name; } }
internal LessonDB(Lectural lecturalDB, DisciplineDB discipline, LessonTypeDB lessonType, LessonDTO lessonDTO) { this.id = lessonDTO.id; this.name = lessonDTO.name; this.sectionName = lessonDTO.sectionName; this.themeName = lessonDTO.themeName; this.countHours = lessonDTO.countHours; this.Lectural = lecturalDB; this.LessonTypeDB = lessonType; this.Discipline = discipline; this.currentNumberOflessonsType = lessonDTO.currentNumberOflessonsType; }