public async Task <IActionResult> Post(SoilTypeRequest request) { try { SoilType soilType = _mapper.Map(request); soilType = await _repository.AddAsync(soilType); return(CreatedAtAction(nameof(GetById), new { id = soilType.Id }, _mapper.Map(soilType))); } catch (DataStoreException e) { _logger.LogError(e.Message, e, request); return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public async Task <IActionResult> Put(Guid id, SoilTypeRequest request) { try { SoilType soilType = await _repository.GetByIdAsync(id); if (soilType == null) { return(NotFound()); } _mapper.Map(soilType, request); await _repository.UpdateAsync(soilType); return(Ok()); } catch (DataStoreException e) { _logger.LogError(e.Message, e, request); return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }