예제 #1
0
        public async Task <ActionResult> CreateInstitution(InstitutionRequest request)
        {
            var result = await _institutionService.CreateInstitution(request);

            if (result.Errors != null)
            {
                return(BadRequest(result.Errors));
            }

            return(Ok(result.Data));
        }
        public ActionResult <InstitutionReadDto> CreateInstitution(InstitutionReadDto insitutionReadDto)
        {
            var institutionModel = _mapper.Map <institution>(insitutionReadDto);

            _repository.CreateInstitution(institutionModel);

            var institutionReadDto = _mapper.Map <InstitutionReadDto>(institutionModel);

            return(CreatedAtRoute(nameof(GetInstitutionById), new { Id = institutionReadDto.id }, institutionReadDto));
        }
예제 #3
0
 public IActionResult CreateInstitution(string name)
 {
     try
     {
         var result = _institutionService.CreateInstitution(name);
         if (result == null)
         {
             return(BadRequest("Неудалось добавить учебное заведение"));
         }
         _logger.LogInformation($"Учебное заведение: {name}, успешно добавлено");
         return(Ok($"Учебное заведение {name} успешно добавлено"));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Ошибка входе добавление учебного заведения");
         return(BadRequest(ex));
     }
 }