public SchoolSubjectWithWeeklyClassesDTO CreateSchoolSubject(SchoolSubjectCreateAndEditDTO dto) { SchoolSubject subject = SchoolSubjectToSchoolSubjectDTOConverters.SchoolSubjectCreateAndEditDTOToSchoolSubject(dto); db.SchoolSubjectsRepository.Insert(subject); db.Save(); //TODO 12: check if the returned object has ID!! return(SchoolSubjectToSchoolSubjectDTOConverters.SchoolSubjectToSchoolSubjectWithWeeklyClassesDTO(subject)); }
public static SchoolSubject SchoolSubjectCreateAndEditDTOToSchoolSubject(SchoolSubjectCreateAndEditDTO dto) { SchoolSubject retVal = new SchoolSubject() { Name = dto.Name, WeeklyClasses = dto.WeeklyClasses }; logger.Info("Converting SchoolSubjectCreateAndEditDTO to SchoolSubject."); return(retVal); }
public SchoolSubjectWithWeeklyClassesDTO EditSchoolSubject(int id, SchoolSubjectCreateAndEditDTO dto) { SchoolSubject subject = db.SchoolSubjectsRepository.GetByID(id); if (subject != null) { subject.Name = dto.Name; subject.WeeklyClasses = dto.WeeklyClasses; db.SchoolSubjectsRepository.Update(subject); db.Save(); } return(SchoolSubjectToSchoolSubjectDTOConverters.SchoolSubjectToSchoolSubjectWithWeeklyClassesDTO(subject)); }