public async Task <StudentResource> AddStudent(StudentVM student)
        {
            var allCourses = await repository.GetAllCourses();

            var studentCourses = allCourses.Where(e => student.favCourses.Contains(e.Id)).ToList();

            if (studentCourses.Count != student.favCourses.Count)
            {
                throw new Exception("One or more course id is not found");
            }
            var studentEntity = student.ToEntity();

            studentEntity.favCourses = studentCourses;
            var id = await repository.AddStudent(studentEntity);

            if (id != 0)
            {
                var newStudent = await repository.GetStudent((int)id);

                return(newStudent.ToResource());
            }
            else
            {
                return(null);
            }
        }
 public void Put(StudentVM subject)
 {
     service.Update(subject.ToEntity());
 }
        public StudentVM Post(StudentVM subject)
        {
            var rs = service.Add(subject.ToEntity());

            return(rs == null ? null : BaseVM <object> .ToModel <StudentVM>(rs));
        }