public async Task <ExchangeDetailsModel> UpdateAsync(string shortcut, ExchangeUpdateModel exchange)
        {
            var existing = await _repository.GetByShortcutAsync(shortcut);

            if (existing == null)
            {
                return(null);
            }

            _mapper.Map(exchange, existing);
            var updated = await _repository.UpdateAsync(existing);

            return(_mapper.Map <ExchangeDetailsModel>(updated));
        }
Beispiel #2
0
        public async Task <ActionResult <ExchangeDetailsModel> > UpdateSTockAsync(string shortcut, [FromBody] ExchangeUpdateModel exchange)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (string.IsNullOrWhiteSpace(shortcut) || exchange == null)
            {
                return(BadRequest());
            }

            try
            {
                var updatedExchange = await _service.UpdateAsync(shortcut, exchange);

                if (updatedExchange == null)
                {
                    return(NotFound());
                }

                return(Ok(updatedExchange));
            }
            catch (DBConcurrencyException)
            {
                return(Conflict());
            }
        }