public OpenOrderResponse OpenOrder(OpenOrderRequest request) { OrderDetailsService service = new OrderDetailsService(); OpenOrderResponse response = new OpenOrderResponse(); try { using (TransactionScope scope = new TransactionScope()) { request.Order = service.GetById(request.OrderId); request.Order.OrderStatusId = 1; request.Order.OrderStatus.OrderStatusId = 1; request.Order.OrderStatus.StatusName = "Open"; if (request.Order != null) { service.Update(request.Order); } // The Complete method commits the transaction. If an exception has been thrown, // Complete is not called and the transaction is rolled back. scope.Complete(); } } catch (Exception ex) { response.IsFailed = true; response.Message = ex.Message; } return(response); }
public OpenOrderResponse OpenOrder(OpenOrderRequest orderRequest) { var symbol = _symbol; var command = orderRequest.OrderType == OrderTypeEnum.BUY ? 0 : 1; var volume = orderRequest.Volume; var price = orderRequest.OrderType == OrderTypeEnum.BUY ? _mqlApi.Ask : _mqlApi.Bid; var slippage = orderRequest.Slippage; var stopLoss = orderRequest.StopLoss; var takeProfit = orderRequest.TakeProfit; var comment = orderRequest.Comment; var magic = orderRequest.Magic; var expiration = orderRequest.Expiration; try { _mqlApi.RefreshRates(); var result = _mqlApi.OrderSend(symbol, command, volume, price, slippage, stopLoss, takeProfit, comment, magic, expiration); return(new OpenOrderResponse { }); } catch (Exception exception) { // Log exception throw; } }
public void TestOpenOrderSuccess() { var request = new OpenOrderRequest(merchantInfo, sessionToken, currency, amount) { MerchantDetails = new MerchantDetails { CustomField1 = "test", CustomField2 = "test", CustomField3 = "test", CustomField4 = "", CustomField5 = "", CustomField6 = "", CustomField7 = "", CustomField8 = "", CustomField9 = "", CustomField10 = "", CustomField11 = "", CustomField12 = "", CustomField13 = "", CustomField14 = "", CustomField15 = "" } }; var response = requestExecutor.OpenOrder(request).GetAwaiter().GetResult(); Assert.IsNotNull(response); Assert.IsEmpty(response.Reason); Assert.AreEqual(ResponseStatus.Success, response.Status); }
public async Task <IHttpActionResult> Post(CreateOrderModel model) { var memberId = User.GetMemberId(); var request = new OpenOrderRequest(memberId, model.FromUnitId, model.ItemId, model.Remarks); return(await Dispatch(request, async r => { return await queryService.GetOrderOverview(r.OrderId); })); }
public async Task Cannot_Open_Order_Without_Required_Permmision() { var member = new Member(1, 1); var handler = CreateHandler(member); var request = new OpenOrderRequest(1, 1, 1); var res = await handler.Handle(request); Assert.IsFalse(res.Success); }
public async Task Can_Create_Order() { var member = new Member(1, 1, Permission.CanConfirmOrder); var createRes = new CreateOrderResponse(1); var handler = CreateHandler(member, createRes); var request = new OpenOrderRequest(1, 1, 1); var res = await handler.Handle(request); Assert.IsTrue(res.Success); Assert.AreEqual(1, res.Value.OrderId); }
/// <summary> /// insert a piece of orderdetails by orderid --by Eric /// </summary> /// <param name="orderdetails"></param> /// <returns></returns> public bool OpenOrder(int id) { OpenOrderRequest request = new OpenOrderRequest(); request.OrderId = id; OpenOrderResponse response = MyChannelFactory.CreateChannel().OpenOrder(request); if (response != null) { if (response.IsFailed == true) { throw (new Exception(response.Message)); } } return(response.IsFailed); }
public void TestEmptyConstructorsUsedForMappingFromConfigFile() { _ = new PaymentRequest(); _ = new SettleTransactionRequest(); _ = new VoidTransactionRequest(); _ = new RefundTransactionRequest(); _ = new GetPaymentStatusRequest(); _ = new OpenOrderRequest(); _ = new InitPaymentRequest(); _ = new Authorize3dRequest(); _ = new Verify3dRequest(); _ = new PayoutRequest(); _ = new GetCardDetailsRequest(); _ = new GetMerchantPaymentMethodsRequest(); Assert.Pass(); }
/// <summary> /// Update a piece of orderdetails by orderid --by Eric /// </summary> /// <param name="orderdetails"></param> /// <returns></returns> public bool OpenOrder(int id) { OpenOrderRequest request = new OpenOrderRequest(); request.OrderId = id; OpenOrderResponse response = MyChannelFactory.CreateChannel().OpenOrder(request); if (response != null) { if (response.IsFailed == true) { ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); log.Error("error", new Exception(response.Message)); log.Fatal("fatal", new Exception(response.Message)); throw (new Exception(response.Message)); } } return(response.IsFailed); }
public void Start() { TrenderOrderManager orderManager = new TrenderOrderManager(_mqlApi, _symbol); var volume = orderManager.GetAvailableVolume(_symbol); OpenOrderRequest openOrderRequest = new OpenOrderRequest { OrderType = _trenDirection == TrendDirectionEnum.UP ? OrderTypeEnum.BUY : OrderTypeEnum.SELL, Volume = volume, // Todo: Get from DB! Slippage = 3, StopLoss = 0, TakeProfit = 0, Comment = "Comment", Magic = 1000000, Expiration = DateTime.MinValue }; OpenOrderResponse openOrderResponse = orderManager.OpenOrder(openOrderRequest); }
public async Task <OpenOrderResponse> OpenOrder( string currency, string amount, List <Item> items = null, OpenOrderPaymentOption paymentOption = null, UserPaymentOption userPaymentOption = null, string paymentMethod = null, string userTokenId = null, string clientUniqueId = null, string clientRequestId = null, string userId = null, string authenticationTypeOnly = null, AmountDetails amountDetails = null, DeviceDetails deviceDetails = null, CashierUserDetails userDetails = null, UserAddress shippingAddress = null, UserAddress billingAddress = null, DynamicDescriptor dynamicDescriptor = null, MerchantDetails merchantDetails = null, Addendums addendums = null, UrlDetails urlDetails = null, string customSiteName = null, string productId = null, string customData = null, string transactionType = null, string isMoto = null, string isRebilling = null, string rebillingType = null, SubMerchant subMerchant = null) { var request = new OpenOrderRequest(merchantInfo, sessionToken, currency, amount) { Items = items, PaymentOption = paymentOption, UserPaymentOption = userPaymentOption, PaymentMethod = paymentMethod, UserTokenId = userTokenId, ClientRequestId = clientRequestId, ClientUniqueId = clientUniqueId, UserId = userId, AuthenticationTypeOnly = authenticationTypeOnly, AmountDetails = amountDetails, DeviceDetails = deviceDetails, UserDetails = userDetails, ShippingAddress = shippingAddress, BillingAddress = billingAddress, DynamicDescriptor = dynamicDescriptor, MerchantDetails = merchantDetails, Addendums = addendums, UrlDetails = urlDetails, CustomSiteName = customSiteName, ProductId = productId, CustomData = customData, TransactionType = transactionType, IsMoto = isMoto, IsRebilling = isRebilling, RebillingType = rebillingType, SubMerchant = subMerchant }; return(await safechargeRequestExecutor.OpenOrder(request)); }
public void TestGetAndSetModelOpenOrderRequest() { var openOrderRequest = new OpenOrderRequest(merchantInfo, sessionToken, currency, amount) { Items = items, PaymentOption = new OpenOrderPaymentOption { Card = new OpenOrderCard { AcquirerId = "", StoredCredentials = new StoredCredentials { StoredCredentialsMode = "0" }, ThreeD = new OpenOrderThreeD { Acquirer = new Acquirer { Bin = null, MerchantId = null, MerchantName = null }, Account = new Account { NameInd = null, Age = null, LastChangeDate = null, LastChangeInd = null, RegistrationDate = null, PasswordChangeDate = null, ResetInd = null, PurchasesCount6M = null, AddCardAttepmts24H = null, TransactionsCount24H = null, TransactionsCount1Y = null, CardSavedDate = null, CardSavedInd = null, AddressFirstUseDate = null, AddressFirstUseInd = null, SuspiciousActivityInd = null }, ConvertNonEnrolled = "", Dynamic3DMode = "", IsDynamic3D = "", V2AdditionalParams = new OpenOrderThreeDV2AdditionalParams { DeliveryEmail = null, DeliveryTimeFrame = null, ExceptionPayment3DAuth = false, GiftCardAmount = null, GiftCardCurrency = null, PreOrderDate = null, PreOrderPurchaseInd = null, RebillExpiry = null, RebillFrequency = null, ReorderItemsInd = null }, } } }, UserPaymentOption = new UserPaymentOption { UserPaymentOptionId = "1" }, PaymentMethod = "", UserTokenId = "", ClientRequestId = "", ClientUniqueId = "", AmountDetails = new AmountDetails { }, DeviceDetails = new DeviceDetails { }, UserDetails = new CashierUserDetails { }, ShippingAddress = new UserAddress { }, BillingAddress = new UserAddress { }, DynamicDescriptor = new DynamicDescriptor { }, MerchantDetails = new MerchantDetails { }, Addendums = new Addendums { }, UrlDetails = new UrlDetails { }, ProductId = "", CustomData = "", TransactionType = "", IsMoto = "", IsRebilling = "0", RebillingType = "", SubMerchant = new SubMerchant { City = "", Id = "", CountryCode = "", }, PreventOverride = "0" }; var response = requestExecutor.OpenOrder(openOrderRequest).GetAwaiter().GetResult(); Assert.IsNotNull(response); Assert.IsEmpty(response.Reason); Assert.AreEqual(ResponseStatus.Success, response.Status); Assert.Pass(); }
public async Task <OpenOrderResponse> OpenOrder(OpenOrderRequest openOrderRequest) { return(await this.PostAsync <OpenOrderResponse, OpenOrderRequest>(openOrderRequest)); }