public async Task <IActionResult> EnrolCourse([FromBody] EnrolDTO enrolDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var user = await _service.FindUser(enrolDTO.UserId);

            if (user == false)
            {
                return(Unauthorized());
            }
            var course = await _service.FindCourse(enrolDTO.CourseId);

            if (course == false)
            {
                return(NotFound("Wybrany kurs nie istnieje"));
            }
            var courseEnrolment = await _service.FindCourseEnrolment(enrolDTO.UserId, enrolDTO.CourseId);

            if (courseEnrolment == true)
            {
                return(BadRequest("Już jesteś zapisany na ten kurs"));
            }
            var result = await _service.EnrolCourseAsync(enrolDTO);

            if (result != null)
            {
                return(Ok(result));
            }

            return(BadRequest("Nie zostałeś zapisany na kurs"));
        }
        public async Task <DateTime> EnrolCourseAsync(EnrolDTO enrolDTO)
        {
            var enrolment = _mapper.Map <CourseEnrolment>(enrolDTO);
            await _repository.EnrolCourseAsync(enrolment);

            return(enrolDTO.EnrolmentDate);
        }