コード例 #1
0
        public async Task <IActionResult> Update(string id, [FromBody] WatchListUpdateModel model)
        {
            var watchList = await GetWatchList(id);

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

            if (watchList.ReadOnly ||
                !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 WatchListDto()
            {
                Id       = id,
                Name     = model.Name,
                Order    = model.Order,
                AssetIds = model.AssetPairIds.ToList()
            };

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

            return(Ok(newWatchList.ToApiModel()));
        }
コード例 #2
0
        async Task <IWatchList> IWatchListsClient.AddCustomAsync(WatchListDto watchList, string clientId)
        {
            var result = await HttpClient.WatchListAddCustomAsync(FromWatchListDto(watchList), clientId);

            var dto = FromWatchListResponse(result);

            return(dto);
        }
コード例 #3
0
        async Task <IWatchList> IWatchListsClient.AddPredefinedAsync(WatchListDto watchList)
        {
            var result = await HttpClient.WatchListAddPredefinedAsync(FromWatchListDto(watchList));

            var data = FromWatchListResponse(result);

            return(data);
        }
コード例 #4
0
        private WatchList FromWatchListDto(WatchListDto item)
        {
            if (item == null)
            {
                return(null);
            }

            return(new WatchList(item.AssetIds, item.Id, item.Name, item.Order, item.ReadOnly));
        }
コード例 #5
0
        public int CreateWatchList(WatchList watchList)
        {
            WatchListDto watchListDto = new WatchListDto();

            watchListDto.MovieID = watchListDto.MovieID;

            int rowcount = db.CreateWatchList(watchListDto);

            return(rowcount);
        }
コード例 #6
0
 public int CreateWatchList(WatchListDto watchListDto)
 {
     using (MySqlConnection conn = GetConnection())
     {
         conn.Open();
         string command = "INSERT INTO watchlist (MovieID, UserID)" +
                          "values ({0}, {1})";
         MySqlCommand cmd      = new MySqlCommand(string.Format(command, watchListDto.MovieID, 1), conn);
         int          rowcount = cmd.ExecuteNonQuery();
         return(rowcount);
     }
 }
コード例 #7
0
        public IHttpActionResult UpdateWatchList(int id, WatchListDto watchListDto)
        {
            //First we validate the object, and throw exception if model is not valid
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var watchListInDb = _context.WatchLists.SingleOrDefault(c => c.Id == id);

            //It's possible that the client sends an invalid Id so we need to check for the existence of the object.
            if (watchListInDb == null)
            {
                return(NotFound());
            }

            Mapper.Map(watchListDto, watchListInDb);

            _context.SaveChanges();

            return(Ok());
        }
コード例 #8
0
        private async Task <IWatchList> FilterAssetPairsAsync(IWatchList watchList, List <string> availableAssetPairIds = null)
        {
            availableAssetPairIds = availableAssetPairIds ?? await GetAvailableAssetPairIdsAsync();

            var filteredAssetPairIds = watchList.AssetIds
                                       .Where(x => availableAssetPairIds.Contains(x))
                                       .ToList();

            if (!filteredAssetPairIds.Any())
            {
                return(null);
            }

            var result = new WatchListDto()
            {
                AssetIds = filteredAssetPairIds,
                Id       = watchList.Id,
                Name     = watchList.Name,
                Order    = watchList.Order,
                ReadOnly = watchList.ReadOnly
            };

            return(result);
        }
コード例 #9
0
 public async Task UpdateCustomWatchListAsync(string clientId, WatchListDto watchList)
 {
     await _assetsServiceUserDataClient.WatchLists.UpdateCustomWatchListAsync(clientId, watchList);
 }
コード例 #10
0
 async Task IWatchListsClient.UpdatePredefinedAsync(WatchListDto watchList)
 {
     await HttpClient.WatchListUpdatePredefinedAsync(FromWatchListDto(watchList));
 }
コード例 #11
0
 async Task IWatchListsClient.UpdateCustomWatchListAsync(string clientId, WatchListDto watchList)
 {
     await HttpClient.WatchListUpdateCustomAsync(FromWatchListDto(watchList), clientId);
 }