Exemplo n.º 1
0
        public InternshipCourseEntity Create(UserEntity userEntity, InternshipCourseEntity internshipCourseEntity)
        {
            InternshipCourse internshipCourse = internshipCourseEntity.ToModel();
            Student          student          = IMSContext.Students.Where(s => s.Id == userEntity.Id).FirstOrDefault();

            if (student == null)
            {
                throw new BadRequestException("user khong tim thay");
            }
            student.InternshipCourses.Add(internshipCourse);
            IMSContext.InternshipCourses.Add(internshipCourse);
            IMSContext.SaveChanges();
            return(new InternshipCourseEntity(internshipCourse));
        }
Exemplo n.º 2
0
 public InternshipCourseEntity Update([FromRoute] Guid internshipCourseId, [FromBody] InternshipCourseEntity internshipCourseEntity)
 {
     return(internshipCourseService.Update(UserEntity, internshipCourseId, internshipCourseEntity));
 }
Exemplo n.º 3
0
 public InternshipCourseEntity Create([FromBody] InternshipCourseEntity internshipCourseEntity)
 {
     return(internshipCourseService.Create(UserEntity, internshipCourseEntity));
 }
Exemplo n.º 4
0
        public InternshipCourseEntity Update(UserEntity userEntity, Guid internshipCourseId, InternshipCourseEntity internshipCourseEntity)
        {
            Student          student          = IMSContext.Students.Where(s => s.Id == userEntity.Id).FirstOrDefault();
            InternshipCourse internshipCourse = IMSContext.InternshipCourses.Where(s => s.Id == internshipCourseId).FirstOrDefault();

            if (internshipCourse == null)
            {
                throw new BadRequestException("Khong tim thay course");
            }
            internshipCourseEntity.ToModel(internshipCourse);
            IMSContext.SaveChanges();
            return(new InternshipCourseEntity(internshipCourse));
        }