コード例 #1
0
        public async Task <ErrorCodeResponse <ProductsErrorCodesContract> > UpdateBatchAsync(
            [FromBody] UpdateProductBatchRequest request)
        {
            var products = request.Requests
                           .Select(kvp =>
            {
                var product       = _convertService.Convert <UpdateProductRequest, Product>(kvp.Value);
                product.ProductId = kvp.Key;
                return(product);
            })
                           .ToList();

            var correlationId = this.TryGetCorrelationId();

            var result = await _productsService.UpdateBatchAsync(products,
                                                                 request.Requests.FirstOrDefault().Value.UserName, correlationId);

            var response = new ErrorCodeResponse <ProductsErrorCodesContract>();

            if (result.IsFailed)
            {
                response.ErrorCode =
                    _convertService.Convert <ProductsErrorCodes, ProductsErrorCodesContract>(
                        result.Error.GetValueOrDefault());
            }

            return(response);
        }
コード例 #2
0
        public async Task <ErrorCodeResponse <ClientProfilesErrorCodesContract> > UpdateClientProfileSettingsAsync(
            [FromBody] UpdateClientProfileSettingsRequest request,
            [FromRoute][Required] string profileId,
            [FromRoute][Required] string typeId)
        {
            var response = new ErrorCodeResponse <ClientProfilesErrorCodesContract>();

            var correlationId = this.TryGetCorrelationId();

            var model = _convertService.Convert <UpdateClientProfileSettingsRequest, ClientProfileSettings>(request);

            model.ClientProfileId = profileId;
            model.AssetTypeId     = typeId;

            try
            {
                await _clientProfileSettingsService.UpdateAsync(model, request.Username, correlationId);
            }
            catch (InvalidMarginValueException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.InvalidMarginValue;
            }
            catch (CannotSetToAvailableException)
            {
                response.ErrorCode =
                    ClientProfilesErrorCodesContract.CannotSetToAvailableBecauseOfRegulatoryRestriction;
            }
            catch (ClientSettingsDoNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.ClientProfileSettingsDoNotExist;
            }
            catch (RegulatorySettingsDoNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.RegulatorySettingsAreMissing;
            }
            catch (InvalidOnBehalfFeeException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.InvalidOnBehalfFeeValue;
            }
            catch (InvalidExecutionFeesRateException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.InvalidExecutionFeesRate;
            }
            catch (InvalidExecutionFeesCapException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.InvalidExecutionFeesCap;
            }
            catch (InvalidExecutionFeesFloorException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.InvalidExecutionFeesFloor;
            }

            return(response);
        }
コード例 #3
0
        public async Task <ErrorCodeResponse <MarketSettingsErrorCodesContract> > DeleteMarketSettingsAsync([Required] string id, [Required] string username)
        {
            var correlationId = this.TryGetCorrelationId();
            var result        = await _marketSettingsService.DeleteAsync(id, username, correlationId);

            var response = new ErrorCodeResponse <MarketSettingsErrorCodesContract>();

            if (result.IsFailed)
            {
                response.ErrorCode = _convertService.Convert <MarketSettingsErrorCodes, MarketSettingsErrorCodesContract>(result.Error.Value);
            }

            return(response);
        }
コード例 #4
0
        public async Task <ErrorCodeResponse <LocalizedValuesErrorCodesContract> > Delete(string locale, string key,
                                                                                          [FromBody] DeleteLocalizedValueRequest request)
        {
            var response      = new ErrorCodeResponse <LocalizedValuesErrorCodesContract>();
            var correlationId = this.TryGetCorrelationId();

            var result = await _localizedValuesService.DeleteAsync(locale, key, request.UserName, correlationId);

            if (result.IsFailed)
            {
                response.ErrorCode = _mapper.Map <LocalizedValuesErrorCodesContract>(result.Error.GetValueOrDefault());
            }

            return(response);
        }
コード例 #5
0
        public async Task <ErrorCodeResponse <MarketSettingsErrorCodesContract> > AddMarketSettingsAsync([FromBody] AddMarketSettingsRequest request)
        {
            var model = _convertService.Convert <AddMarketSettingsRequest, MarketSettingsCreateOrUpdateDto>(request);

            var correlationId = this.TryGetCorrelationId();
            var result        = await _marketSettingsService.AddAsync(model, request.Username, correlationId);

            var response = new ErrorCodeResponse <MarketSettingsErrorCodesContract>();

            if (result.IsFailed)
            {
                response.ErrorCode = _convertService.Convert <MarketSettingsErrorCodes, MarketSettingsErrorCodesContract>(result.Error.Value);
            }

            return(response);
        }
コード例 #6
0
        public async Task <ErrorCodeResponse <ProductsErrorCodesContract> > DeleteAsync(string productId, [FromBody] DeleteProductRequest request)
        {
            var correlationId = this.TryGetCorrelationId();
            var result        = await _productsService.DeleteAsync(productId, request.UserName, correlationId);

            var response = new ErrorCodeResponse <ProductsErrorCodesContract>();

            if (result.IsFailed)
            {
                response.ErrorCode =
                    _convertService.Convert <ProductsErrorCodes, ProductsErrorCodesContract>(
                        result.Error.GetValueOrDefault());
            }

            return(response);
        }
コード例 #7
0
        public async Task <ErrorCodeResponse <CurrenciesErrorCodesContract> > DeleteAsync(
            [FromRoute][Required] string id, [FromBody] DeleteCurrencyRequest request)
        {
            var correlationId = this.TryGetCorrelationId();
            var result        = await _currenciesService.DeleteAsync(id, request.UserName, correlationId);

            var response = new ErrorCodeResponse <CurrenciesErrorCodesContract>();

            if (result.IsFailed)
            {
                response.ErrorCode =
                    _convertService.Convert <CurrenciesErrorCodes, CurrenciesErrorCodesContract>(result.Error.Value);
            }

            return(response);
        }
コード例 #8
0
        public async Task <ErrorCodeResponse <ProductsErrorCodesContract> > AddAsync(AddProductRequest request)
        {
            var product       = _convertService.Convert <AddProductRequest, Product>(request);
            var correlationId = this.TryGetCorrelationId();
            var result        = await _productsService.InsertAsync(product, request.UserName, correlationId);

            var response = new ErrorCodeResponse <ProductsErrorCodesContract>();

            if (result.IsFailed)
            {
                response.ErrorCode =
                    _convertService.Convert <ProductsErrorCodes, ProductsErrorCodesContract>(
                        result.Error.GetValueOrDefault());
            }

            return(response);
        }
コード例 #9
0
        public async Task <ErrorCodeResponse <CurrenciesErrorCodesContract> > AddAsync(
            [FromBody] AddCurrencyRequest request)
        {
            var currency      = _convertService.Convert <AddCurrencyRequest, Currency>(request);
            var correlationId = this.TryGetCorrelationId();
            var result        = await _currenciesService.InsertAsync(currency, request.UserName, correlationId);

            var response = new ErrorCodeResponse <CurrenciesErrorCodesContract>();

            if (result.IsFailed)
            {
                response.ErrorCode =
                    _convertService.Convert <CurrenciesErrorCodes, CurrenciesErrorCodesContract>(result.Error.Value);
            }

            return(response);
        }
コード例 #10
0
        public async Task <ErrorCodeResponse <ClientProfilesErrorCodesContract> > UpdateAssetTypeAsync
            ([FromRoute][Required] string id, [FromBody] UpdateAssetTypeRequest request)
        {
            var response = new ErrorCodeResponse <ClientProfilesErrorCodesContract>();

            var correlationId = this.TryGetCorrelationId();

            var model = _convertService.Convert <UpdateAssetTypeRequest, AssetType>(request);

            model.Id = id;

            try
            {
                await _assetTypesService.UpdateAsync(model, request.Username, correlationId);
            }
            catch (AlreadyExistsException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.AlreadyExist;
            }
            catch (AssetTypeDoesNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.AssetTypeDoesNotExist;
            }
            catch (BrokerSettingsDoNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.BrokerSettingsDoNotExist;
            }
            catch (RegulatoryTypeDoesNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.RegulatoryTypeInMdmIsMissing;
            }
            catch (RegulatorySettingsDoNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.RegulatorySettingsAreMissing;
            }
            catch (RegulationConstraintViolationException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.RegulationConstraintViolation;
            }
            catch (UnderlyingCategoryDoesNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.UnderlyingCategoryDoesNotExist;
            }

            return(response);
        }
        public async Task <ErrorCodeResponse <ClientProfilesErrorCodesContract> > AddClientProfileAsync([FromBody] AddClientProfileRequest request)
        {
            var response = new ErrorCodeResponse <ClientProfilesErrorCodesContract>();

            var correlationId = this.TryGetCorrelationId();

            try
            {
                var clientProfile = new ClientProfileWithTemplate(
                    request.Id,
                    request.RegulatoryProfileId,
                    request.ClientProfileTemplateId,
                    request.IsDefault);
                await _regulatoryProfilesService.InsertAsync(clientProfile, request.Username, correlationId);
            }
            catch (ClientProfileDoesNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.ClientProfileDoesNotExist;
            }
            catch (AlreadyExistsException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.AlreadyExist;
            }
            catch (BrokerSettingsDoNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.BrokerSettingsDoNotExist;
            }
            catch (RegulatoryProfileDoesNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.RegulatoryProfileInMdmIsMissing;
            }
            catch (RegulatorySettingsDoNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.RegulatorySettingsAreMissing;
            }
            catch (RegulationConstraintViolationException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.RegulationConstraintViolation;
            }
            catch (ClientProfileNonDefaultUpdateForbiddenException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.NonDefaultUpdateForbidden;
            }

            return(response);
        }
        public async Task <ErrorCodeResponse <TradingConditionErrorCodesContract> > UpdateClientTradingConditions(
            [FromBody] UpdateClientTradingConditionsBulkRequest request)
        {
            var updates = request.Updates.Select(p => (p.ClientId, p.TradingConditionId)).ToList();
            var result  = await _accountManagementService.UpdateClientTradingConditions(updates,
                                                                                        request.Username);

            var response = new ErrorCodeResponse <TradingConditionErrorCodesContract>();

            if (result.IsFailed)
            {
                response.ErrorCode =
                    _convertService.Convert <TradingConditionErrorCodes, TradingConditionErrorCodesContract>(result.Error.Value);
            }

            return(response);
        }
コード例 #13
0
        public async Task <ErrorCodeResponse <ProductsErrorCodesContract> > MarkMultipleAsDiscontinuedAsync([FromBody] MarkProductsAsDiscontinuedRequest request)
        {
            var correlationId = this.TryGetCorrelationId();

            var result = await _productsService.DiscontinueBatchAsync(request.ProductIds, request.UserName, correlationId);

            var response = new ErrorCodeResponse <ProductsErrorCodesContract>();

            if (result.IsFailed)
            {
                response.ErrorCode =
                    _convertService.Convert <ProductsErrorCodes, ProductsErrorCodesContract>(
                        result.Error.GetValueOrDefault());
            }

            return(response);
        }
コード例 #14
0
        public async Task <ErrorCodeResponse <LocalizedValuesErrorCodesContract> > Add(
            [FromBody] AddLocalizedValueRequest value)
        {
            var response = new ErrorCodeResponse <LocalizedValuesErrorCodesContract>();

            var correlationId = this.TryGetCorrelationId();

            var result =
                await _localizedValuesService.AddAsync(_mapper.Map <LocalizedValue>(value), value.UserName, correlationId);

            if (result.IsFailed)
            {
                response.ErrorCode = _mapper.Map <LocalizedValuesErrorCodesContract>(result.Error.GetValueOrDefault());
            }

            return(response);
        }
        public async Task <ErrorCodeResponse <ProductCategoriesErrorCodesContract> > UpsertAsync(
            [FromBody] AddProductCategoryRequest request)
        {
            var result =
                await _productCategoriesService.GetOrCreate(request.Category, request.UserName,
                                                            this.TryGetCorrelationId());

            var response = new ErrorCodeResponse <ProductCategoriesErrorCodesContract>();

            if (result.IsFailed)
            {
                response.ErrorCode =
                    _convertService.Convert <ProductCategoriesErrorCodes, ProductCategoriesErrorCodesContract>(
                        result.Error.GetValueOrDefault());
            }

            return(response);
        }
        public async Task <ErrorCodeResponse <TickFormulaErrorCodesContract> > AddAsync(
            [FromBody] AddTickFormulaRequest request)
        {
            var model = _convertService.Convert <AddTickFormulaRequest, ITickFormula>(request);

            var correlationId = this.TryGetCorrelationId();
            var result        = await _tickFormulaService.AddAsync(model, request.Username, correlationId);

            var response = new ErrorCodeResponse <TickFormulaErrorCodesContract>();

            if (result.IsFailed)
            {
                response.ErrorCode =
                    _convertService.Convert <TickFormulaErrorCodes, TickFormulaErrorCodesContract>(result.Error
                                                                                                   .Value);
            }

            return(response);
        }
コード例 #17
0
        public async Task <ErrorCodeResponse <LocalizedValuesErrorCodesContract> > Update(string locale, string key,
                                                                                          [FromBody] UpdateLocalizedValueRequest value)
        {
            var response      = new ErrorCodeResponse <LocalizedValuesErrorCodesContract>();
            var correlationId = this.TryGetCorrelationId();

            var model = _mapper.Map <LocalizedValue>(value);

            model.Locale = locale;
            model.Key    = key;

            var result = await _localizedValuesService.UpdateAsync(model, value.UserName, correlationId);

            if (result.IsFailed)
            {
                response.ErrorCode = _mapper.Map <LocalizedValuesErrorCodesContract>(result.Error.GetValueOrDefault());
            }

            return(response);
        }
コード例 #18
0
        public async Task <ErrorCodeResponse <ClientProfilesErrorCodesContract> > DeleteAssetTypeAsync([FromRoute][Required] string id, [FromQuery][Required] string username)
        {
            var response = new ErrorCodeResponse <ClientProfilesErrorCodesContract>();

            var correlationId = this.TryGetCorrelationId();

            try
            {
                await _assetTypesService.DeleteAsync(id, username, correlationId);
            }
            catch (AssetTypeDoesNotExistException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.AssetTypeDoesNotExist;
            }
            catch (CannotDeleteAssetTypeAssignedToAnyProductException)
            {
                response.ErrorCode = ClientProfilesErrorCodesContract.CannotDeleteAssetTypeAssignedToAnyProduct;
            }

            return(response);
        }