示例#1
0
        public async Task <ResponseModel <IMarginTradingWatchList> > AddWatchList([FromBody] WatchList model)
        {
            var clientId = User.GetClaim(ClaimTypes.NameIdentifier);

            if (clientId == null)
            {
                return(ResponseModel <IMarginTradingWatchList> .CreateFail(ResponseModel.ErrorCodeType.NoAccess, "Wrong token"));
            }

            var result = new ResponseModel <IMarginTradingWatchList>();

            if (model.AssetIds == null || model.AssetIds.Count == 0)
            {
                return(ResponseModel <IMarginTradingWatchList> .CreateInvalidFieldError("AssetIds", "AssetIds should not be empty"));
            }

            var addResult = await _watchListService.AddAsync(model.Id, clientId, model.Name, model.AssetIds);

            switch (addResult.Status)
            {
            case WatchListStatus.AssetNotFound:
                return(ResponseModel <IMarginTradingWatchList> .CreateFail(ResponseModel.ErrorCodeType.AssetNotFound, $"Asset '{addResult.Message}' is not found or not allowed"));

            case WatchListStatus.ReadOnly:
                return(ResponseModel <IMarginTradingWatchList> .CreateFail(ResponseModel.ErrorCodeType.InconsistentData, "This watch list is readonly"));
            }

            result.Result = addResult.Result;

            return(result);
        }
示例#2
0
        public void Is_AllAssets_NotChanged()
        {
            var lists        = _watchListService.GetAllAsync(ClientId).Result;
            var allAsstsList = lists.FirstOrDefault(item => item.Name == "All assets");

            Assert.IsNotNull(allAsstsList);

            var result = _watchListService.AddAsync(allAsstsList.Id, ClientId, "New all assets", new List <string> {
                "EURUSD"
            }).Result;

            Assert.AreEqual(WatchListStatus.ReadOnly, result.Status);
        }