Esempio n. 1
0
        public GradeDTOOut AddSubjectToGrade(int id, GradeSubjectDTOIn gradeSubject)
        {
            Grade             grade    = GetGradeId(id);
            HashSet <Subject> subjects = new HashSet <Subject>();

            foreach (var ID in gradeSubject.SubjectID)
            {
                var subject = subjectsService.GetSubjectByID(ID);
                subjects.Add(subject);
            }

            grade.Subjects = subjects;
            db.GradesRepository.Update(grade);

            IEnumerable <SubjectDTO> subjectDTO = subjects.Select(x => Utilities.ConverterDTO.SimpleDTOConverter <SubjectDTO>(x));

            GradeDTOOut gradeDTO = new GradeDTOOut()
            {
                Id        = grade.Id,
                GradeYear = grade.GradeYear,
                Subjects  = subjectDTO
            };

            return(gradeDTO);
        }
Esempio n. 2
0
        public IHttpActionResult PutSubjectToGrade(int id, GradeSubjectDTOIn newGrade)
        {
            GradeDTOOut createdGrade = gradesService.AddSubjectToGrade(id, newGrade);

            return(Created("", createdGrade));
        }