Пример #1
0
        public async Task <IActionResult> PostAsync([FromBody] StudentDto student)
        {
            var entity = _mapper.Map <Student>(student);
            var course = await _readRepository.FindSingleByAsync(n => n.Name == student.CourseDto.Name, Includes.StudentsAndTeacher());

            if (course == null)
            {
                return(NotFound("Course Not Found"));
            }
            entity.Course = course;

            if (!entity.Course.HasVacancy)
            {
                return(new JsonResult(new { error = "The course has no more vacancies." })
                {
                    StatusCode = StatusCodes.Status406NotAcceptable
                });
            }
            _queueService.SendToQueueToSaveAsync(entity);

            return(new JsonResult(new { notification = "Your signature is being processed. When completed, you'll receive an email notification." })
            {
                StatusCode = StatusCodes.Status200OK
            });
        }