예제 #1
0
 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);
 }
예제 #2
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);
        }
예제 #3
0
        public void Handle(ConfirmOrder message)
        {
            Data.OrderId        = message.OrderId;
            Data.OrderConfirmed = true;

            ValidateOrder();
        }
예제 #4
0
 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);
 }
예제 #5
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);
        }
예제 #6
0
        public void Handle(ConfirmOrder command)
        {
            var order = repository.Get(command.OrderId);

            order.Confirm();
            repository.Save(order, command.Id.ToString());
        }
예제 #7
0
        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();
        }
예제 #8
0
        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();
        }
예제 #9
0
        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;
        }
예제 #11
0
        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);
    }
예제 #13
0
        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));
    }
예제 #15
0
 private void OnButtonConfirmOrderClick(object o, EventArgs e)
 {
     LabelMessageNotEnoughProducts.Visible = false;
     if (CheckNumberProducts())
     {
         ConfirmOrder?.Invoke();
     }
     else
     {
         LabelMessageNotEnoughProducts.Visible = true;
     }
 }
예제 #16
0
 private void OnButtonConfirmOrderClick(object o, EventArgs e)
 {
     if (_deleteCheckBoxes.Count != 0)
     {
         ConfirmOrder?.Invoke();
     }
     else
     {
         MessageBox.Show("Нельзя оформить заказ без товара. Добавьте хотя бы один товар, а затем продолжите.",
                         "Добавьте товар");
     }
 }
예제 #17
0
        private PaymentViewModel CompleteRegistrationWithoutPayment(Guid orderId)
        {
            var confirmationCommand = new ConfirmOrder {
                OrderId = orderId
            };

            this._commandBus.Send(confirmationCommand);

            return(new PaymentViewModel {
                ConferenceCode = this.ConferenceAlias.Code, OrderId = orderId
            });
        }
예제 #18
0
        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);
        }
예제 #19
0
        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));
        }
예제 #20
0
        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);
                }
        }
예제 #21
0
        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);
        }
예제 #22
0
        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);
        }
예제 #23
0
        /*
         * 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 });
            }
        }
예제 #24
0
 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
     });
 }
예제 #25
0
        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());
        }
예제 #26
0
 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);
 }
예제 #28
0
        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);
        }
예제 #29
0
 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();
 }
예제 #30
0
 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
     })));
 }