public async Task AddAsync([FromBody] InstrumentEditModel model) { try { var instrument = Mapper.Map <Instrument>(model); await _instrumentService.AddAsync(instrument); } catch (InvalidOperationException exception) { throw new ValidationApiException(HttpStatusCode.BadRequest, exception.Message); } }
public async Task AddAsync([FromBody] InstrumentModel model, string userId) { if (string.IsNullOrEmpty(userId)) { throw new ValidationApiException("Used id required"); } try { var instrument = Mapper.Map <Instrument>(model); await _instrumentService.AddAsync(instrument, userId); } catch (EntityAlreadyExistsException) { throw new ValidationApiException(HttpStatusCode.Conflict, "Instrument already exists."); } }