public async Task <CancelTradeResponseModel> CancelTrade(string userId, CancelTradeModel model, bool isApi)
        {
            try
            {
                using (var tradeService = CreateService())
                {
                    var response = await tradeService.CancelTradeAsync(new CancelTradeItemRequest
                    {
                        CancelType  = model.CancelType,
                        TradeId     = model.TradeId,
                        TradePairId = model.TradePairId,
                        UserId      = new Guid(userId),
                        IsApi       = isApi
                    }).ConfigureAwait(false);

                    return(new CancelTradeResponseModel
                    {
                        Error = response.Error,
                        CanceledOrders = response.CanceledOrderIds,
                        DataUpdates = await ProcessDataUpdates(response),
                        Notifications = await ProcessNotifications(response),
                    });
                }
            }
            catch (Exception)
            {
                return(new CancelTradeResponseModel {
                    Error = "An Error occurred canceling trade, if problem persist please contact Cryptopia Support"
                });
            }
        }
Example #2
0
        public async Task <ActionResult> CancelTrade(CancelTradeModel model)
        {
            var result = await TradeWriter.CancelTrade(User.Id(), model);

            if (result.HasErrors)
            {
                return(JsonError());
            }

            return(JsonSuccess());
        }
Example #3
0
        public async Task <IWriterResult <bool> > CancelTrade(string userId, CancelTradeModel model)
        {
            model.UserId = userId;
            var result = await TradeService.QueueCancel(model);

            if (result.HasError)
            {
                return(WriterResult <bool> .ErrorResult(result.Error));
            }

            return(WriterResult <bool> .SuccessResult());
        }