private void Init() { orderServiceClient = new OrderServiceClient(); Order order = orderServiceClient.Read(_orderId); if (order != null) { Customer customer = order._customer; if (customer != null) { lblCustomerName.Text = customer._fName + " " + customer._lName; lblCustomerAddress.Text = customer._address; lblCustomerCity.Text = customer._zipCity._zipCode + " " + customer._zipCity._city; lblCustomerEmail.Text = customer._email; lblCustomerPhone.Text = customer._phone; } IEnumerable <UniqueProduct> uniqueProducts = orderServiceClient.GetAllProductsByOrderId(_orderId); listBoxProducts.Items.Clear(); foreach (UniqueProduct up in uniqueProducts) { listBoxProducts.Items.Add(up._product._name); } } }
public string Checkout() { // Checkout the basket and return the id provided by order service var items = GetProducts(); string[] ItemIds = items.Select(d => d.Id.ToString()).ToArray(); var Total = items.Sum(s => decimal.Parse(s.Price)); OrderServiceClient client = new OrderServiceClient(); OrderService.Order order = new OrderService.Order { CustomerName = "Apoteket", ItemIds = ItemIds, Total = Total }; string ordernumber = string.Empty; try { ordernumber = client.Place(order); } catch (Exception ex) { throw ex; } return(ordernumber); }
public async void TestWarningRuleIsNotApplied() { var rules = new RulesServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null); CreateDefaultRules(rules); var rule = rules.GetRules().Single(r => r.Category == RuleCategory.WarningRule && r.Type == RuleType.Default); rules.DeactivateRule(rule.Id); var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var order = new CreateOrderRequest { Id = Guid.NewGuid(), PickupAddress = TestAddresses.GetAddress1(), PickupDate = DateTime.Now, DropOffAddress = TestAddresses.GetAddress2(), Settings = new BookingSettings { ChargeTypeId = ChargeTypes.PaymentInCar.Id, VehicleTypeId = 1, ProviderId = 13, Phone = "5145551212", Passengers = 6, NumberOfTaxi = 1, Name = "Joe Smith" }, }; var validation = await sut.ValidateOrder(order); Assert.IsFalse(validation.HasWarning); Assert.IsNullOrEmpty(validation.Message); }
private async Task <OrderValidationResult> ValidateOrder(Action <CreateOrderRequest> update, string testZone = null) { var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var order = new CreateOrderRequest { Id = Guid.NewGuid(), PickupAddress = TestAddresses.GetAddress1(), PickupDate = null, DropOffAddress = TestAddresses.GetAddress2(), Settings = new BookingSettings { ChargeTypeId = ChargeTypes.PaymentInCar.Id, VehicleTypeId = 1, ProviderId = Provider.ApcuriumIbsProviderId, Phone = "5145551212", Passengers = 6, NumberOfTaxi = 1, Name = "Joe Smith" }, ClientLanguageCode = "en" }; if (update != null) { update(order); } return(await sut.ValidateOrder(order, testZone)); }
public void when_creating_order_without_passing_settings() { var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var order = new CreateOrderRequest { Id = Guid.NewGuid(), PickupAddress = TestAddresses.GetAddress1(), DropOffAddress = TestAddresses.GetAddress2(), Estimate = new RideEstimate { Price = 10, Distance = 3 }, Settings = new BookingSettings { Phone = "5145551212", Country = new CountryISOCode("CA") }, ClientLanguageCode = SupportedLanguages.fr.ToString() }; var ex = Assert.Throws <WebServiceException>(async() => await sut.CreateOrder(order)); Assert.AreEqual("CreateOrder_SettingsRequired", ex.ErrorMessage); }
static void Main(string[] args) { OrderServiceClient client = new OrderServiceClient(); Console.WriteLine(client.HelloWho("Justin")); Console.Read(); client.Close(); }
public ActionResult OrderHistoryDetails(DateTime?orderDate) //id - номер заказа { UserOrderDetailsViewModel orderDetails = new UserOrderDetailsViewModel(); List <UserOrderDetailsItem> orderDetailsItems = new List <UserOrderDetailsItem>(); using (var client = new OrderServiceClient()) // получаем данные заказа { //надо найти сам заказа var order = client.GetOrders().FirstOrDefault(o => o.OrderDate == orderDate); orderDetails.Id = order.Id; orderDetails.UserName = System.Web.HttpContext.Current.User.Identity.Name; orderDetails.OrderPrice = order.OrderPrice; orderDetails.Details = new Func <IEnumerable <UserOrderDetailsItem> >(() => { foreach (var orderItem in client.GetOrderDetails().Where(o => o.OrderId == order.Id)) { orderDetailsItems.Add(new UserOrderDetailsItem { Id = orderItem.Id, ProductName = orderItem.Product, Quantity = orderItem.Quantity, TotalPrice = orderItem.TotalPrice }); } return(orderDetailsItems.AsEnumerable()); })(); } return(View(orderDetails)); //UserOrderDetailsViewModel }
public ActionResult <string> Get(int id) { OrderServiceClient client = new OrderServiceClient(); var result = client.GetOrderDataAsync(id); return(Ok(result)); }
public void when_creating_order_with_promotion_but_not_using_card_on_file() { var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var order = new CreateOrderRequest { Id = Guid.NewGuid(), PickupAddress = TestAddresses.GetAddress1(), DropOffAddress = TestAddresses.GetAddress2(), Estimate = new RideEstimate { Price = 10, Distance = 3 }, Settings = new BookingSettings { ChargeTypeId = ChargeTypes.PaymentInCar.Id, VehicleTypeId = 1, ProviderId = Provider.ApcuriumIbsProviderId, Phone = "5145551212", Country = new CountryISOCode("CA"), Passengers = 6, NumberOfTaxi = 1, Name = "Joe Smith", LargeBags = 1, AccountNumber = "123", CustomerNumber = "0" }, ClientLanguageCode = SupportedLanguages.fr.ToString(), PromoCode = "123" }; var ex = Assert.Throws <WebServiceException>(async() => await sut.CreateOrder(order)); Assert.AreEqual("Vous devez sélectionner le Paiement In App pour utiliser une promotion.", ex.ErrorMessage); }
public async void can_cancel_it() { var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); await sut.CancelOrder(_orderId); OrderStatusDetail status = null; for (var i = 0; i < 10; i++) { status = await sut.GetOrderStatus(_orderId); if (string.IsNullOrEmpty(status.IBSStatusId)) { Thread.Sleep(1000); } else { break; } } Assert.NotNull(status); Assert.AreEqual(OrderStatus.Canceled, status.Status); Assert.AreEqual(VehicleStatuses.Common.CancelledDone, status.IBSStatusId); }
//Disposer alel clienter og null them // public void Dispose() { _barClient = null; _drinkClient = null; _orderClient = null; _customerClient = null; }
public ActionResult CreateOrder() { using (ServiceHelper serviceHelper = new ServiceHelper()) { OrderServiceClient orderProxy = serviceHelper.GetOrderServiceClient(); Order order = new Order(); order.OrderLines = new List <OrderLine>(); List <OrderDrinkViewModel> drinks = (List <OrderDrinkViewModel>)Session["shoppingcart"]; foreach (OrderDrinkViewModel drink in drinks) { OrderLine ol = new OrderLine { Drink = new OrderServiceReference.Drink { Id = drink.DrinkId }, Quantity = drink.Quantity, Subtotal = drink.Subtotal, Names = drink.Names, }; order.OrderLines.Add(ol); order.Status = Status.NotDone; order.OrderTime = DateTime.Now; order.Bar = new OrderServiceReference.Bar(); order.Bar.ID = drink.BarId; order.Customer = new Customer(); order.Customer.Id = AuthHelper.CurrentUser.Id; } ViewBag.OrderNumber = orderProxy.CreateOrder(order); Session["shoppingcart"] = new List <OrderDrinkViewModel>(); return(View(ViewBag.OrderNumber)); } }
public ActionResult OrderInfo() { OrderServiceClient client = new OrderServiceClient(); var model = client.Find(); return(Json(model, JsonRequestBehavior.AllowGet)); }
public async void when_order_rated_ratings_should_not_be_null() { var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var orderRatingsRequest = new OrderRatingsRequest { OrderId = _orderId, Note = "Note", RatingScores = new List <RatingScore> { new RatingScore { RatingTypeId = Guid.NewGuid(), Score = 1, Name = "Politness" }, new RatingScore { RatingTypeId = Guid.NewGuid(), Score = 2, Name = "Safety" }, new RatingScore { RatingTypeId = Guid.NewGuid(), Score = 2, Name = "Safety" } } }; await sut.RateOrder(orderRatingsRequest); var orderRatingDetails = await sut.GetOrderRatings(_orderId); Assert.NotNull(orderRatingDetails); Assert.That(orderRatingDetails.Note, Is.EqualTo(orderRatingsRequest.Note)); Assert.That(orderRatingDetails.RatingScores.Count, Is.EqualTo(2)); }
private void Init() { orderServiceClient = new OrderServiceClient(); IEnumerable <Order> orders = orderServiceClient.GetAll(); int i = 0; foreach (Order order in orders) { dataGridView1.Rows.Add(); if (order._customer != null) { Customer c = order._customer; dataGridView1.Rows[i].Cells[0].Value = c._fName + " " + c._lName; } bool done = order._processed; dataGridView1.Rows[i].Cells[1].Value = order._id; dataGridView1.Rows[i].Cells[2].Value = order._delivery; dataGridView1.Rows[i].Cells[3].Value = done; dataGridView1.Rows[i].Cells[4].Value = "->"; i++; } }
private void Form1_Load(object sender, EventArgs e) { proxy = new OrderServiceClient("OrderService_Tcp"); products = proxy.ListProducts(); productbindingSource.DataSource = products; proxy = null; }
public void UpdateOrderTest() { var order = new OrdersHelper().AddOrder(); OrdersHelper.PrintFullOrderInfo(order); var products = new ProductServiceClient().GetAllProducts(); order.ShipAddress = "New Ship Address"; order.Order_Details = new[] { new Order_Detail() { Discount = 0, ProductID = products[products.Length - 1 >= 0 ? products.Length - 1 : 0].ProductID, Quantity = 100, UnitPrice = 3 }, new Order_Detail() { Discount = 0, ProductID = products[products.Length - 2 >= 0 ? products.Length - 2 : 0].ProductID, Quantity = 200, UnitPrice = 2 }, new Order_Detail() { Discount = 0, ProductID = products[products.Length - 3 >= 0 ? products.Length - 3 : 0].ProductID, Quantity = 300, UnitPrice = 1 }, }; var updatedOrder = new OrderServiceClient(new InstanceContext(this)).UpdateOrder(order); Assert.AreEqual(updatedOrder.ShipAddress, "New Ship Address"); Assert.AreEqual(updatedOrder.Order_Details.Length, 3); OrdersHelper.PrintFullOrderInfo(updatedOrder); }
public int ShipRequest(int id) { OrderServiceClient serviceStore = new OrderServiceClient(); using (SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["warehouse_db"].ConnectionString)) { try { c.Open(); string sql = "update [Request] set ship_date = @now output inserted.order_id where id = @id"; SqlCommand cmd = new SqlCommand(sql, c); cmd.Parameters.Add("@now", SqlDbType.DateTime2, 7).Value = DateTime.Now; cmd.Parameters.Add("@id", SqlDbType.Int).Value = id; int orderId = (Int32)cmd.ExecuteScalar(); { serviceStore.ChangeOrderState(orderId, 'S', DateTime.Now.AddDays(2).ToString("yyyy-MM-dd")); } } catch (SqlException e) { Console.WriteLine(e); return(-1); } finally { c.Close(); } } return(0); }
private void orderbtn_Click(object sender, EventArgs e) { OrderServiceClient orderSoapClient = new OrderServiceClient(); ItemServiceClient itemSoapClient = new ItemServiceClient(); ClientServiceClient clientSoapClient = new ClientServiceClient(); OrderReference.Client client = new OrderReference.Client(); client.Name = this.nameClienttb.Text; client.PhoneNumber = this.phoneNumbertb.Text; OrderReference.Item item1 = new OrderReference.Item(); item1.NameItem = this.nameItem1tb.Text; item1.Length = Double.Parse(this.length1tb.Text); item1.Width = Double.Parse(this.width1tb.Text); item1.Height = Double.Parse(this.height1tb.Text); item1.Weight = Double.Parse(this.weight1tb.Text); OrderReference.Item item2 = new OrderReference.Item(); item2.NameItem = this.nameItem1tb.Text; item2.Length = Double.Parse(this.length2tb.Text); item2.Width = Double.Parse(this.width2tb.Text); item2.Height = Double.Parse(this.height2tb.Text); item2.Weight = Double.Parse(this.weight2tb.Text); List <OrderReference.Item> items = new List <OrderReference.Item>(); items.Add(item1); items.Add(item2); OrderReference.Order order = new OrderReference.Order(); order.Date = this.datetb.Text; order.Address = this.addresstb.Text; order.Loader = this.loader.Checked; order.Client = client; order.Items = items.ToArray(); List <OrderReference.Order> orders = new List <OrderReference.Order>(); orders.Add(order); client.Orders = orders.ToArray(); item1.Order = order; item2.Order = order; try { //clientSoapClient.AddClient((ClientReference.Client)client); orderSoapClient.AddOrder(order); //itemSoapClient.AddItem((ItemReference.Item) item1); //itemSoapClient.AddItem((ItemReference.Item) item2); } catch (Exception error) { System.Diagnostics.Debug.Write("Error is occur " + error); } }
public async void can_not_access_order_status_another_account() { await CreateAndAuthenticateTestAccount(); var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); Assert.Throws <WebServiceException>(async() => await sut.GetOrderStatus(_orderId)); }
public void DeleteOrderTest() { var orderForDelete = new OrdersHelper().AddOrder(); var service = new OrderServiceClient(new InstanceContext(this)); service.DeleteOrder(orderForDelete.OrderID); }
public ActionResult DeleteShoppingCartItem(string shoppingCartItemId) { using (var proxy = new OrderServiceClient()) { proxy.DeleteShoppingCartItem(new Guid(shoppingCartItemId)); return(Json(null)); } }
public async void create_and_get_a_valid_order() { var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var data = await sut.GetOrderStatus(_orderId); Assert.AreEqual(OrderStatus.Created, data.Status); Assert.AreEqual("Joe Smith", data.Name); }
public ActionResult UpdateShoppingCartItem(string shoppingCartItemId, int quantity) { using (var proxy = new OrderServiceClient()) { proxy.UpdateShoppingCartItem(new Guid(shoppingCartItemId), quantity); return(Json(null)); } }
public ActionResult Orders() { using (var proxy = new OrderServiceClient()) { var model = proxy.GetOrdersForUser(this.UserId); return(View(model)); } }
protected void Page_Load(object sender, EventArgs e) { _proxy = new OrderServiceClient(); if (Session["Error"] != null) { ErrorLabel.Text = Session["Error"].ToString(); } }
public ActionResult Order(string id) { using (var proxy = new OrderServiceClient()) { var model = proxy.GetOrder(new Guid(id)); return(View(model)); } }
public async void ibs_order_was_created() { var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var order = await sut.GetOrder(_orderId); Assert.IsNotNull(order); Assert.IsNotNull(order.IBSOrderId); }
public ActionResult Confirm(string id) { using (var proxy = new OrderServiceClient()) { proxy.Confirm(new Guid(id)); return(RedirectToSuccess("确认收货成功!", "Orders", "Home")); } }
public ActionResult ShoppingCart() { using (var proxy = new OrderServiceClient()) { var model = proxy.GetShoppingCart(UserId); return(View(model)); } }
public ActionResult UpdateShoppingCartItem(string shoppingCartItemId, int quantity) { using (var proxy = new OrderServiceClient()) { proxy.UpdateShoppingCartItem(new Guid(shoppingCartItemId), quantity); return Json(null); } }
public ActionResult ShoppingCart() { using (var proxy = new OrderServiceClient()) { var model = proxy.GetShoppingCart(UserId); return View(model); } }
public async void GetOrderList() { var sut = new OrderServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var orders = await sut.GetOrders(); Assert.NotNull(orders); }
public ActionResult _LoginPartial() { if (User.Identity.IsAuthenticated) { using (var proxy = new OrderServiceClient()) { ViewBag.ShoppingCartItems = proxy.GetShoppingCartItemCount(UserId); } } return PartialView(); }
public ActionResult AddToCart(string productId, string items) { using (var proxy = new OrderServiceClient()) { int quantity = 0; if (!int.TryParse(items, out quantity)) quantity = 1; proxy.AddProductToCart(UserId, new Guid(productId), quantity); return RedirectToAction("ShoppingCart"); } }
private void deleteOrderButton_Click(object sender, EventArgs e) { int orderToDelete = int.Parse(this.orderToDeleteTextBox.Text); OrderServiceClient proxy = new OrderServiceClient(); proxy.ClientCredentials.UserName.UserName = "******"; proxy.ClientCredentials.UserName.Password = "******"; bool success = proxy.DeleteOrder(orderToDelete); if (success) MessageBox.Show("DeleteOrder() call was successful."); else MessageBox.Show("DeleteOrder() call failed."); }
public IEnumerable<Order> GetOrders() { using (var client = new OrderServiceClient("NetTcpBinding_IOrderService")) { var hasElements = true; while (hasElements) { hasElements = false; foreach (var order in client.GetOrders()) { yield return order; hasElements = true; } } } }
private void getOrdersButton_Click(object sender, EventArgs e) { this.responseTextBox.Text = ""; OrderServiceClient proxy = new OrderServiceClient(); proxy.ClientCredentials.UserName.UserName = "******"; proxy.ClientCredentials.UserName.Password = "******"; OrderMessage[] orderMessages = proxy.GetOrders(); foreach (OrderMessage orderMessage in orderMessages) { string orderString = string.Format( "ID: {0}\r\nSender: {1}\r\nRecipient: {2}\r\nItemNumber: {3}\r\nItemDescription: {4}\r\n\r\n", orderMessage.Id, orderMessage.Sender, orderMessage.Recipient, orderMessage.ItemNumber, orderMessage.ItemDescription); this.responseTextBox.Text += orderString; } }
public void UpdateOrder(OrderDto orderDto) { OrderServiceClient orderServiceClient = new OrderServiceClient(); try { orderServiceClient.UpdateOrder(new UpdateOrderRequest { OrderDto = orderDto }); } catch (Exception exception) { string message = string.Format("An error occured while in type :{0} , method :{1} ", "OrderServiceManager", MethodBase.GetCurrentMethod().Name); CommonLogManager.Log.Error(message, exception); throw; } finally { orderServiceClient.Close(); } }
static void Main() { using (var client = new OrderServiceClient()) { bool finished; do { var order = GenerateOrder(); // get a fake order Console.WriteLine("Adding order."); client.AddOrder(order); Console.WriteLine("There are {0} order(s).", client.GetOrders().Count); Console.WriteLine("Add another order? (Y/N)"); finished = Console.ReadLine() == "N"; } while (!finished); } Console.WriteLine("Hit ENTER to quit."); Console.ReadLine(); }
private void putOrderButton_Click(object sender, EventArgs e) { OrderMessage newOrder = new OrderMessage(); newOrder.Currency = this.currencyTextBox.Text; newOrder.DeliveryDate = this.deliveryDateTimePicker.Value; newOrder.ItemDescription = this.itemDescriptionTextBox.Text; newOrder.ItemNumber = this.itemNumberTextBox.Text; newOrder.OrderDate = this.orderDateTimePicker.Value; newOrder.Price = int.Parse(this.priceTextBox.Text); newOrder.Quantity = int.Parse(this.quantityTextBox.Text); newOrder.Recipient = this.recipientTextBox.Text; newOrder.Sender = this.senderTextBox.Text; newOrder.Text = this.textTextBox.Text; OrderServiceClient proxy = new OrderServiceClient(); proxy.ClientCredentials.UserName.UserName = "******"; proxy.ClientCredentials.UserName.Password = "******"; bool success = proxy.PutOrder(newOrder); if (success) MessageBox.Show("PutOrder() call was successful."); else MessageBox.Show("PutOrder() call failed."); }
public void GetOrders(int customerID,Action<GetOrderByCustomerResponse,Exception> callback) { OrderServiceClient orderServiceClient = new OrderServiceClient(); try { if (callback != null) orderServiceClient.GetOrderByCustomerCompleted += (s,e)=>callback(e.Result,e.Error); orderServiceClient.GetOrderByCustomerAsync(new GetOrderByCustomerReguest { CustomerID = customerID }); } catch (Exception exception) { string message = string.Format("An error occured while in type :{0} , method :{1} ", "OrderServiceManager", MethodBase.GetCurrentMethod().Name); CommonLogManager.Log.Error(message, exception); throw; } finally { orderServiceClient.Close(); } }
private static void TimerOnTick(object sender, EventArgs eventArgs) { double price; // ReSharper disable PossibleNullReferenceException if(_browser != null && double.TryParse(_browser.Document.GetElementById("last_last").InnerText, NumberStyles.Float, _numberFormat, out price)) // ReSharper restore PossibleNullReferenceException { using(var client = new OrderServiceClient()) { SetPriceDataContractResponse response = null; try { response = client.SetPrice(new SetPriceDataContractRequest { ProcessId = Process.GetCurrentProcess().Id, SymbolId = _symbolId, Price = price }); } catch(Exception ex) { _logger.Error(ex); // Application.Exit(); return; } if(!string.IsNullOrEmpty(response.Error)) { _logger.Error("Error got from server: {0}", response.Error); } // if(response.StopSignal) { _logger.Info("Stop signal received. Symbol: {0}", _symbolId); // Application.Exit(); } } } }
public JsonResult Buy(long id, int idx) { using(var ctx = new DataModelContext()) { using(var client = new OrderServiceClient()) { var order = ctx.Orders.SingleOrDefault(o => o.StatsExampleId == id && o.Index == idx); // Open order if(order == null) { var openResponse = client.OpenOrder(new OpenOrderRequest { ExampleId = id, OrderType = OrderTypes.Buy }); if(!string.IsNullOrEmpty(openResponse.Error)) { LogManager.GetCurrentClassLogger().Error(openResponse.Error); // return this.Json(new {Response = SetOrderErrors.Other}); } // return this.Json(new {Response = openResponse.SetOrderErrors}); } // Close order var closeResponse = client.CloseOrder(new CloseOrderRequest {ExampleId = id, Index = idx}); if(!string.IsNullOrEmpty(closeResponse.Error)) { LogManager.GetCurrentClassLogger().Error(closeResponse.Error); // return this.Json(new {Response = SetOrderErrors.Other}); } // return this.Json(new {Response = closeResponse.SetOrderErrors}); } } }
static void Main(string[] args) { int i = 0; while (true) { var method = Console.ReadLine(); if (method == "trigger") { var db = new ssb_dbEntities1(); var order = new Order { OrderID = Guid.NewGuid(), CustomerName = "trigger" + i }; db.Orders.Add(order); db.SaveChanges(); } else if (method == "wcf") { SsbBinding clientBinding = new SsbBinding(); clientBinding.SqlConnectionString = Utils.Connectionstring("clientBinding"); clientBinding.UseEncryption = false; clientBinding.UseActionForSsbMessageType = true; clientBinding.Contract = Utils.ChannelContract; OrderServiceClient client = new OrderServiceClient(clientBinding, new EndpointAddress(Utils.ServiceEndpointAddress)); var order = new OrderService.Proxies.Order { OrderId = Guid.NewGuid(), CustomerName = "wcf" + i }; client.SubmitOrder(order); client.Close(); } i++; } }
public JsonResult GetPrice(string id, long exampleId, int openOrdersFlags, int closeOrdersFlags) { using(var ctx = new DataModelContext()) { using(var client = new OrderServiceClient()) { var orders = ctx.Orders.Where(o => o.StatsExampleId == exampleId).OrderBy(o => o.Index).ToList(); var idxsForReload = new List<int>(); // Check orders state foreach(var order in orders) { if(((openOrdersFlags >> order.Index) & 1) == 0) { idxsForReload.Add(order.Index); continue; } if(order.ClosePrice.HasValue && ((closeOrdersFlags >> order.Index) & 1) == 0) idxsForReload.Add(order.Index); } var lastOrder = orders.LastOrDefault(); if(lastOrder != null && lastOrder.ClosePrice.HasValue && idxsForReload.Contains(lastOrder.Index) && lastOrder.Index < ctx.GetTransactionsCount() - 1 && !idxsForReload.Contains(lastOrder.Index + 1)) idxsForReload.Add(lastOrder.Index + 1); // var response = client.GetPrice(new GetPriceDataContractRequest {SymbolId = id}); if(response.MarketIsClosed) return this.Json(new {MarketIsClosed = true}, JsonRequestBehavior.AllowGet); // return this.Json(new { response.Price, TotalPips = orders.Count == 0 ? 0 : orders.Sum(o => o.Pips), IdxsForReload = idxsForReload }, JsonRequestBehavior.AllowGet); } } }
public ActionResult DeleteShoppingCartItem(string shoppingCartItemId) { using (var proxy = new OrderServiceClient()) { proxy.DeleteShoppingCartItem(new Guid(shoppingCartItemId)); return Json(null); } }
public JsonResult SetTakeProfit(long id, int idx, string takeProfit) { using(var client = new OrderServiceClient()) { using(var ctx = new DataModelContext()) { var numberFormat = new NumberFormatInfo {NumberDecimalSeparator = ".", NumberGroupSeparator = ","}; var takeProfitValue = string.IsNullOrEmpty(takeProfit) ? (double?)null : double.Parse(takeProfit, numberFormat); var stopLossValue = ctx.Orders.Single(o => o.StatsExampleId == id && o.Index == idx).StopLoss; var response = client.ChangeOrder(new ChangeOrderRequest { ExampleId = id, Index = idx, TakeProfit = takeProfitValue, StopLoss = stopLossValue }); if(!string.IsNullOrEmpty(response.Error)) { LogManager.GetCurrentClassLogger().Error(response.Error); // return this.Json(new {Response = SetOrderErrors.Other}); } // return this.Json(new {Response = response.SetOrderErrors}); } } }
public ActionResult Checkout() { using (var proxy = new OrderServiceClient()) { var model = proxy.Checkout(this.UserId); return View(model); } }
public ActionResult Orders() { using (var proxy = new OrderServiceClient()) { var model = proxy.GetOrdersForUser(this.UserId); return View(model); } }
public ActionResult Confirm(string id) { using (var proxy = new OrderServiceClient()) { proxy.Confirm(new Guid(id)); return RedirectToSuccess("确认收货成功!", "Orders", "Home"); } }
public ActionResult DeleteStatsExample([DataSourceRequest] DataSourceRequest request, StatsExampleModel model) { try { if(model != null) { using(var ctx = new DataModelContext()) { var example = ctx.StatsExamples.Include("StatsType").Include("Orders").Single(e => e.Id == model.Id); example.Deleted = true; var lastOrder = example.Orders.OrderBy(o => o.Index).LastOrDefault(); if(lastOrder != null && !lastOrder.ClosePrice.HasValue) { using(var client = new OrderServiceClient()) { var response = client.GetPrice(new GetPriceDataContractRequest {SymbolId = example.StatsType.TypeId}); if(!string.IsNullOrEmpty(response.Error)) { LogManager.GetCurrentClassLogger().Error(response.Error); } var price = response.Price; if(price.HasValue) { var typeConfig = ((TransactionTypesConfigSection)ConfigurationManager.GetSection("TransactionTypesConfig")).Types.Cast<TypeElementConfig>().ToList().Single(tc => tc.Id == example.StatsType.TypeId); lastOrder.ClosePrice = lastOrder.OrderType == OrderTypes.Buy ? Math.Round(price.Value - Settings.Default.Spread * typeConfig.SpreadTickValue, HomeController.GetDecimalDigits(typeConfig.SpreadTickValue)) : Math.Round(price.Value + Settings.Default.Spread * typeConfig.SpreadTickValue, HomeController.GetDecimalDigits(typeConfig.SpreadTickValue)); lastOrder.Pips = Convert.ToInt32(Math.Round((lastOrder.OrderType == OrderTypes.Buy ? (lastOrder.ClosePrice.Value - lastOrder.OpenPrice) : (lastOrder.OpenPrice - lastOrder.ClosePrice.Value)) / typeConfig.SpreadTickValue, 0)); // Log var log = OrderLog.CreateLog(lastOrder, OrderLogTypes.Close); ctx.OrderLogs.Add(log); } } } // ctx.SaveChanges(); } } } catch(Exception ex) { LogManager.GetCurrentClassLogger().Error(ex); } // return this.Json(new[] {model}.ToDataSourceResult(request, this.ModelState)); }
public ActionResult Orders() { using(var proxy = new OrderServiceClient()) { var model = proxy.GetAllOrders(); return View(model); } }
public ActionResult Order(string id) { using (var proxy = new OrderServiceClient()) { var model = proxy.GetOrder(new Guid(id)); return View(model); } }
public ActionResult DispatchOrder(string id) { using (var proxy = new OrderServiceClient()) { proxy.Dispatch(new Guid(id)); return RedirectToSuccess(string.Format("订单 {0} 已成功发货!", id.ToUpper()), "Orders", "Admin"); } }