예제 #1
0
        public async Task <IActionResult> AddAsync([FromBody] AssessmentAddOrUpdateModel assessmentAddOrUpdateModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var assessmentCreateDto = _mapper.Map <AssessmentCreateDto>(assessmentAddOrUpdateModel);
            var statusCode          = await _assessmentService.AddAsync(assessmentCreateDto);

            var response = _assessmentResponseComposer.ComposeForCreate(statusCode, assessmentCreateDto);

            return(response);
        }
예제 #2
0
        public async Task <IActionResult> UpdateAsync(int?id, [FromBody] AssessmentAddOrUpdateModel assessmentAddOrUpdateModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (id.HasValue)
            {
                var assessmentUpdateDto = _mapper.Map <AssessmentUpdateDto>(assessmentAddOrUpdateModel);
                assessmentUpdateDto.Id = id.Value;
                var statusCode = await _assessmentService.UpdateAsync(assessmentUpdateDto);

                var response = _assessmentResponseComposer.ComposeForUpdate(statusCode);
                return(response);
            }

            return(BadRequest());
        }