private void Trading(string[] st) { using (ConnectKHOpenAPI api = new ConnectKHOpenAPI(new FreeVersion(), new SpecifyKospi200 { Stop = IStopLossAndRevenue.StopLossAndRevenue.UnUsed, BasicAssets = 35000000, Division = false, Reaction = int.Parse(st[0]), ShortMinPeriod = int.Parse(st[1]), ShortDayPeriod = int.Parse(st[2]), LongMinPeriod = int.Parse(st[3]), LongDayPeriod = int.Parse(st[4]), ShortTickPeriod = 5, LongTickPeriod = 60, Strategy = string.Concat(st[0], ".", st[1], ".", st[2], ".", st[3], ".", st[4]) })) { ConfirmOrder cf = ConfirmOrder.Get(); panel.Controls.Add(api); panel.Controls.Add(cf); Location = new Point(2, 1000); StartPosition = FormStartPosition.Manual; Size = cf.Size; Opacity = 0.65; cf.Dock = DockStyle.Fill; cf.BackColor = Color.FromArgb(203, 212, 206); api.Dock = DockStyle.Fill; api.Hide(); api.SendQuit += OnReceiveDialogClose; ShowDialog(); } Dispose(); Environment.Exit(0); }
public void Init() { this.fakeBus = A.Fake <IBusClient>(); var path1 = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(path1, "App_Data")); // create test data this.orders = JsonLoad.Orders(); this.restaurants = JsonLoad.Restaurants(); this.users = JsonLoad.User(); order = orders.FirstOrDefault(); this.confirmOrder = JsonLoad.ConfirmOrder(); // setup DbSet var set = A.Fake <DbSet <OrderService.Data.Model.Order> >(o => o.Implements(typeof(IQueryable <Order>)) .Implements(typeof(IDbAsyncEnumerable <Order>))).SetupData(this.orders); var setUser = A.Fake <DbSet <OrderService.Data.Model.User> >(o => o.Implements(typeof(IQueryable <User>)) .Implements(typeof(IDbAsyncEnumerable <User>))).SetupData(this.users); var setRestaurant = A.Fake <DbSet <OrderService.Data.Model.Restaurant> >(o => o.Implements(typeof(IQueryable <Restaurant>)) .Implements(typeof(IDbAsyncEnumerable <Restaurant>))).SetupData(this.restaurants); // arrange this.dataContext = A.Fake <Data.OrderDataContext>(); A.CallTo(() => dataContext.Orders.Add(A <Order> .Ignored)).Returns(order); A.CallTo(() => dataContext.Orders).Returns(set); A.CallTo(() => dataContext.Users).Returns(setUser); A.CallTo(() => dataContext.Restaurants).Returns(setRestaurant); }
public void Handle(ConfirmOrder message) { Data.OrderId = message.OrderId; Data.OrderConfirmed = true; ValidateOrder(); }
private void Trading(string[] st) { using (ConnectKHOpenAPI api = new ConnectKHOpenAPI(new FreeVersion(), new SpecifyKosdaq150 { Stop = IStopLossAndRevenue.StopLossAndRevenue.UnUsed, BasicAssets = 5000000, Division = false, Reaction = int.Parse(st[0]), ShortMinPeriod = int.Parse(st[1]), ShortDayPeriod = int.Parse(st[2]), LongMinPeriod = int.Parse(st[3]), LongDayPeriod = int.Parse(st[4]), ShortTickPeriod = 5, LongTickPeriod = 60, Strategy = string.Concat(st[0], ".", st[1], ".", st[2], ".", st[3], ".", st[4]) })) { ConfirmOrder cf = ConfirmOrder.Get(); webBrowser.Show(); tableLayoutPanel.RowStyles.Clear(); tableLayoutPanel.Controls.Add(webBrowser, 0, tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 70))); tableLayoutPanel.Controls.Add(panel, 0, tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 50))); panel.Controls.Add(api); panel.Controls.Add(cf); cf.Dock = DockStyle.Fill; api.Dock = DockStyle.Fill; api.Hide(); panel.BorderStyle = BorderStyle.None; WindowState = FormWindowState.Maximized; api.SendQuit += OnReceiveDialogClose; ShowDialog(); } Dispose(); Environment.Exit(0); }
public CE Conferma(OrderResponse orderResponse, CE ce, WsCEClient client) { // solo postFatturazione ComunicazioniElettroniche.Common.Frontend.DataContracts.OpzionePagamento op = new OpzionePagamento(); op.DescrizioneTipoPagamento = string.Empty; // puo' essere solo postfatturazione op.IdTipoPagamento = string.Empty; for (int i = 0; i < orderResponse.PaymentTypes.Length; i++) { if (orderResponse.PaymentTypes[i].PostPayment) { op.DescrizioneTipoPagamento = orderResponse.PaymentTypes[i].TypeDescription; op.IdTipoPagamento = orderResponse.PaymentTypes[i].TypeId; op.PostFatturazione = true; break; } } // Prepare confirm request ConfirmOrder confirm = new ConfirmOrder { IdOrder = orderResponse.IdOrder, PaymentType = new PaymentType { TypeId = op.IdTipoPagamento, PostPayment = true } }; ce.Body = SerializationUtility.SerializeToXmlElement(confirm); client.SubmitRequest(ref ce); return(ce); }
public void Handle(ConfirmOrder command) { var order = repository.Get(command.OrderId); order.Confirm(); repository.Save(order, command.Id.ToString()); }
public ActionResult ConfirmOrder(string shippingAddress, string paymentMethod) { string status = string.Empty; string currentUser = string.Empty; ConfirmOrder confirmOrder = new ConfirmOrder(); string orderStatus = string.Empty; try { if (Session["CurrentUser"] != null) { currentUser = ((UserManager)Session["CurrentUser"]).EmailID; confirmOrder.shippingAddress = shippingAddress; confirmOrder.paymentMethod = paymentMethod; confirmOrder.userId = currentUser; } var data = Newtonsoft.Json.JsonConvert.SerializeObject(confirmOrder); string apiUrl = ConfigurationManager.AppSettings["HCLCartServiceAPI"]; WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiUrl + "Cart/ConfirmOrder", data); if (json == "true") { orderStatus = "Order Placed"; } } catch (Exception ex) { log.Error(ex.Message); } return(RedirectToAction("Index", "Product")); //return View(); }
private void StartTrading(Balance bal, ConfirmOrder order, AccountSelection account, ConnectKHOpenAPI api) { Controls.Add(api); splitContainerBalance.Panel1.Controls.Add(order); splitContainerBalance.Panel2.Controls.Add(bal); api.Dock = DockStyle.Fill; order.Dock = DockStyle.Fill; bal.Dock = DockStyle.Fill; bal.BackColor = Color.FromArgb(203, 212, 206); order.BackColor = Color.FromArgb(121, 133, 130); api.Hide(); account.SendSelection += OnReceiveAccount; splitContainerBalance.Panel2MinSize = 3; splitContainerBalance.Panel1MinSize = 96; order.SendTab += OnReceiveTabControl; bal.SendReSize += OnReceiveSize; if (font.Equals(DialogResult.OK)) { foreach (Control control in order.Controls.Find("checkBox", true)) { control.Font = new Font("Consolas", control.Font.Size + 0.75F, FontStyle.Bold); } } ResumeLayout(); }
private List <OrderInfo> GetRefunds() { List <OrderInfo> OI = ConfirmOrder.GetRefunds(); Console.WriteLine(OI.Count.ToString()); return(OI); }
public async Task<ConfirmOrder> Response(MessageDirectory.Request.ConfirmOrder request, MessageContext context) { ConfirmOrder response = new ConfirmOrder(); this.dataContext = DataUtility.GetDataContext(dataContext); using (dataContext) { var user = await dataContext.Users.SingleOrDefaultAsync(p => p.Id == request.UserId); if (user == null) { Exception ex = new Exception("User Doesnt not exist"); ex.Data.Add("Email",request.UserId); throw ex; } var restaurant = await dataContext.Restaurants.SingleOrDefaultAsync(p => p.Id == request.RestaurantId); if (restaurant == null) { Exception ex = new Exception("Restaurant Doesnt not exist"); ex.Data.Add("Id", request.RestaurantId); throw ex; } var order = new Order() { Amount = request.Amount.Value, Address = request.Address, User = user, Restaurant = restaurant, CreateDate = DateTime.Now, PhoneNumber = request.PhoneNumber, Email = request.Email, City = request.City, DeliveryType = (Data.Enum.DeliveryType)request.DeliveryType, Products = request.Products.Select(p => new Product() { ProductId = p.ProductId, Quantity = p.Quantity }).ToList(), }; dataContext.Orders.Add(order); await dataContext.SaveChangesAsync(); OrderConfirmed orderConfiremd = new OrderConfirmed() { Id = order.Id }; response.id = order.Id; await Bus.PublishAsync(orderConfiremd); } return response; }
public ServiceRes Distributor_ConfirmOrder(ConfirmOrder confirmOrder) { ServiceRes serviceRes = new ServiceRes(); try { if (confirmOrder.Request != null) { int retValue = 0; foreach (var order in confirmOrder.Request) { SqlParameter[] sqlParameter = new SqlParameter[5]; sqlParameter[0] = new SqlParameter { ParameterName = "@MemberId", Value = order.UserId }; sqlParameter[1] = new SqlParameter { ParameterName = "@Order_Id", Value = order.OrderId }; sqlParameter[2] = new SqlParameter { ParameterName = "@Product_Id", Value = order.ProductId }; sqlParameter[3] = new SqlParameter { ParameterName = "@Order_Status", Value = "D" }; sqlParameter[4] = new SqlParameter { ParameterName = "@Flag", Value = "OS" }; retValue = SqlHelper.ExecuteNonQuery("USP_DistributorOrder", sqlParameter); if (retValue > 0) { EmailerRepository emailerRepository = EmailerRepository.GetInstance; if (emailerRepository.Send(order.EmailAddress)) { serviceRes.IsSuccess = true; serviceRes.ReturnCode = "200"; serviceRes.ReturnMsg = "Success"; } } else { serviceRes.IsSuccess = false; serviceRes.ReturnCode = "400"; serviceRes.ReturnMsg = "Failed"; }; } } } catch (Exception ex) { serviceRes.IsSuccess = false; serviceRes.ReturnCode = "400"; serviceRes.ReturnMsg = "Exception occurred."; LogManager.WriteLog(ex); } return(serviceRes); }
public void Handle(PlaceOrderResponse placeOrderResponse) { log.Info($"Received OrderPlaced. OrderId: {placeOrderResponse.OrderId}. Worker: {placeOrderResponse.WorkerName}"); var confirmOrder = new ConfirmOrder { OrderId = placeOrderResponse.OrderId }; bus.Reply(confirmOrder); }
private ActionResult CompleteRegistrationWithoutPayment(Guid orderId) { var confirmationCommand = new ConfirmOrder { OrderId = orderId }; this.commandBus.Send(confirmationCommand); return(RedirectToAction("ThankYou", new { conferenceCode = this.ConferenceAlias.Code, orderId })); }
public Task Handle(PlaceOrderResponse placeOrderResponse, IMessageHandlerContext context) { log.Info($"Received OrderPlaced. OrderId: {placeOrderResponse.OrderId}. Worker: {placeOrderResponse.WorkerName}"); var confirmOrder = new ConfirmOrder { OrderId = placeOrderResponse.OrderId }; return(context.Reply(confirmOrder)); }
private void OnButtonConfirmOrderClick(object o, EventArgs e) { LabelMessageNotEnoughProducts.Visible = false; if (CheckNumberProducts()) { ConfirmOrder?.Invoke(); } else { LabelMessageNotEnoughProducts.Visible = true; } }
private void OnButtonConfirmOrderClick(object o, EventArgs e) { if (_deleteCheckBoxes.Count != 0) { ConfirmOrder?.Invoke(); } else { MessageBox.Show("Нельзя оформить заказ без товара. Добавьте хотя бы один товар, а затем продолжите.", "Добавьте товар"); } }
private PaymentViewModel CompleteRegistrationWithoutPayment(Guid orderId) { var confirmationCommand = new ConfirmOrder { OrderId = orderId }; this._commandBus.Send(confirmationCommand); return(new PaymentViewModel { ConferenceCode = this.ConferenceAlias.Code, OrderId = orderId }); }
public async Task OrderConfirNotExistingUser() { ConfirmOrder confirmOrder = this.confirmOrder; var sub = new ConfirmOrderRPCSubscriber(fakeBus); var result = await sub.Response(confirmOrder, new MessageContext() { GlobalRequestId = Guid.NewGuid() }); Assert.IsNotNull(result); }
public async Task <ActionResult <RegBookResponseObj> > ConfirmOrder([FromBody] ConfirmOrder requestObj) { ConfirmOrderCommand command = _mapper.Map <ConfirmOrderCommand>(requestObj); var response = await _mediator.Send(command); if (response.OrderId < 1 || !response.Status.IsSuccessful) { return(BadRequest(response)); } var locatioUri = _uriService.GetBookUri(response.OrderId.ToString()); return(Created(locatioUri, response)); }
public static ConfirmOrder ConfirmOrder() { string jsonFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataSources", "ConfirmOrder.json"); // deserialize JSON from a file using (StreamReader sr = File.OpenText(jsonFilePath)) using (JsonReader reader = new JsonTextReader(sr)) { JsonSerializer serializer = new JsonSerializer(); ConfirmOrder confirmOrder = serializer.Deserialize <ConfirmOrder>(reader); return(confirmOrder); } }
public ConfirmOrder ConfirmOrder( EventAggregator eventAggregator, IEmailSender emailSender, IPaymentHandler paymentHandler) { var confirmOrder = new ConfirmOrder( new HandleSendEmail(eventAggregator, emailSender), new HandleMakePayment(eventAggregator, paymentHandler)); eventAggregator.Register(confirmOrder); return(confirmOrder); }
public void CreateOrder() { ConfirmOrder confirmOrder = this.confirmOrder; this.bus = BusBuilder.CreateMessageBus(); var sub = new ConfirmOrderRPCSubscriber(bus, dataContext); var result = sub.Response(confirmOrder, new MessageContext() { GlobalRequestId = Guid.NewGuid() }).Result; Assert.IsNotNull(result); }
/* * private ActionResult CompleteRegistrationWithThirdPartyProcessorPayment(PricedOrder order, int orderVersion) * { * var paymentCommand = CreatePaymentCommand(order); * * this.commandBus.Send(paymentCommand); * * var paymentAcceptedUrl = this.Url.Action("ThankYou", new { conferenceCode = this.ConferenceAlias.Code, order.OrderId }); * var paymentRejectedUrl = this.Url.Action("SpecifyRegistrantAndPaymentDetails", new { conferenceCode = this.ConferenceAlias.Code, orderId = order.OrderId, orderVersion }); * * return RedirectToAction( * "ThirdPartyProcessorPayment", * "Payment", * new * { * conferenceCode = this.ConferenceAlias.Code, * paymentId = paymentCommand.PaymentId, * paymentAcceptedUrl, * paymentRejectedUrl * }); * } * * private InitiateThirdPartyProcessorPayment CreatePaymentCommand(PricedOrder order) * { * // TODO: should add the line items? * * var description = "Registration for " + this.ConferenceAlias.Name; * var totalAmount = order.Total; * * var paymentCommand = * new InitiateThirdPartyProcessorPayment * { * PaymentId = GuidUtil.NewSequentialId(), * ConferenceId = this.ConferenceAlias.Id, * PaymentSourceId = order.OrderId, * Description = description, * TotalAmount = totalAmount * }; * * return paymentCommand; * } */ private object CompleteRegistrationWithoutPayment(Guid orderId) { var confirmationCommand = new ConfirmOrder { OrderId = orderId }; commandBus.Send(confirmationCommand); using (var context = _factory.CreateReadOnly()) { return(new { conferenceCode = this.WorkshopAlias.Code, orderId }); } }
private void OnReceiveClose(object sender, DialogClose e) { SuspendLayout(); StartTrading(Balance.Get(), ConfirmOrder.Get(), new AccountSelection(), new ConnectKHOpenAPI()); strategy = new Strategy(new Specify { Reaction = e.Reaction, ShortDayPeriod = e.ShortDay, ShortTickPeriod = e.ShortTick, LongDayPeriod = e.LongDay, LongTickPeriod = e.LongTick, HedgeType = e.Hedge }); }
public ActionResult OrderReview([Bind(Include = "AddressId")] ConfirmOrder bind) { string userName = this.User.Identity.Name; if (this.ModelState.IsValid) { service.CreateOrder(bind, userName); return(RedirectToAction("ConfirmOrder")); } return(View()); }
public ActionResult Confirm(ConfirmOrder req) { if (ModelState.IsValid) { if (_orderRepository.CheckStatusOrder(req.OrderId) == 0) { if (_orderRepository.CheckCouponInOrder(req.UserId, req.CouponId)) { Order order = _orderRepository.ConfirmOrder(req.OrderId, req.UserId); if (order != null) { Coupon coupon = _couponRepository.Get(req.CouponId); if (coupon != null) { if (order.CouponId == null) { if (coupon.Status == 1) { if (coupon.ExpiryDate >= DateTime.Now) { if (order.TotalPrice >= coupon.Condition) { order.TotalPrice = req.TotalPrice; order.CouponId = req.CouponId; order.OrderTime = DateTime.Now; order.Status = 1; if (_orderRepository.SaveChanges() == 1) { return(Ok()); } return(BadRequest(JsonConvert.SerializeObject(new { message = "Server Error." }))); } return(BadRequest(JsonConvert.SerializeObject(new { message = "The user is not eligible to receive the coupon." }))); } return(BadRequest(JsonConvert.SerializeObject(new { message = "The coupon has expired." }))); } return(BadRequest(JsonConvert.SerializeObject(new { message = "The coupon is unavailable." }))); } return(BadRequest(JsonConvert.SerializeObject(new { message = "The order can not take 2 coupons. " }))); } return(BadRequest(JsonConvert.SerializeObject(new { message = "The coupon not found." }))); } return(BadRequest(JsonConvert.SerializeObject(new { message = "The order is not match to user." }))); } return(BadRequest(JsonConvert.SerializeObject(new { message = "The coupon has been used." }))); } return(BadRequest(JsonConvert.SerializeObject(new { message = "The order has done." }))); } return(BadRequest(ModelState)); }
public static string ConfirmOrderToString(ConfirmOrder obj) { try { var stringJson = JsonConvert.SerializeObject(obj); return(EncryptUtils.Encrypt(stringJson, System.Text.Encoding.Unicode)); } catch (Exception ex) { Logger.Write("Đã xảy ra lỗi trong quá trình mã hóa object to string: " + ex, true); throw; } return(null); }
protected virtual ConfirmOrder GetConfirmRequest(string idOrdine, string typeDescription) { ConfirmOrder confirmOrder = new ConfirmOrder(); confirmOrder.IdOrder = idOrdine; confirmOrder.PaymentType = new PaymentType { PostPayment = true, PostPaymentSpecified = true, TypeDescription = typeDescription, TypeId = "6" }; return(confirmOrder); }
private void StartTrading(Balance bal, ConfirmOrder order, AccountSelection account, ConnectKHOpenAPI api) { Controls.Add(api); splitContainerBalance.Panel1.Controls.Add(order); splitContainerBalance.Panel2.Controls.Add(bal); api.Dock = DockStyle.Fill; order.Dock = DockStyle.Fill; bal.Dock = DockStyle.Fill; bal.BackColor = Color.FromArgb(203, 212, 206); order.BackColor = Color.FromArgb(121, 133, 130); api.Hide(); account.SendSelection += OnReceiveAccount; splitContainerBalance.Panel2MinSize = 3; splitContainerBalance.Panel1MinSize = 96; order.SendTab += OnReceiveTabControl; bal.SendReSize += OnReceiveSize; ResumeLayout(); }
private void OnReceiveClose(object sender, DialogClose e) { SuspendLayout(); StartTrading(Balance.Get(), ConfirmOrder.Get(), new AccountSelection(), new ConnectKHOpenAPI()); BeginInvoke(new Action(() => Strategy = new Strategy(new Specify { Reaction = e.Reaction, ShortDayPeriod = e.ShortDay, ShortTickPeriod = e.ShortTick, LongDayPeriod = e.LongDay, LongTickPeriod = e.LongTick, HedgeType = e.Hedge, Base = e.Base, Sigma = e.Sigma, Percent = e.Percent, Max = e.Max, Quantity = e.Quantity, Time = e.Time }))); }