Пример #1
0
        public async Task <IActionResult> Update(string id, [FromBody] WatchListUpdateModel model)
        {
            var watchList = await GetWatchList(id);

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

            if (watchList.ReadOnlyProperty ||
                !await IsValidAsync(model.AssetPairIds) ||
                string.IsNullOrEmpty(model.Name))
            {
                return(BadRequest());
            }

            var watchlists = await GetAllWatchlists();

            if (watchlists.Any(item => item.Name == model.Name && item.Id != watchList.Id))
            {
                return(BadRequest());
            }

            var newWatchList = new WatchList
            {
                Id       = id,
                Name     = model.Name,
                Order    = model.Order,
                AssetIds = model.AssetPairIds.ToList()
            };

            await _assetsHelper.UpdateCustomWatchListAsync(_requestContext.ClientId, newWatchList);

            return(Ok(newWatchList.ToApiModel()));
        }