public void loadOrderList() { loadSomeData(); OrderService orderService = new OrderService(); List<Order> orders = orderService.GetOrders(); setUpDataGrid(orders); }
public ActionResult DetailsPayment(DetailsPayment model) { if (ModelState.IsValid) { ShoppingCartBLL shoppingBLL = ShoppingCartBLL.GetCart(this.HttpContext); DonDatHang order = shoppingBLL.CreateOrder(model, this.User.Identity.Name); OrderService service = new OrderService(); int id = service.CreateOrder(order); if (id > 0) { shoppingBLL.EmptyCart(); return RedirectToAction("Complete", new { id = id }); } ModelState.AddModelError("", "Tạo đơn hàng thất bại, vui lòng thử lại!"); } var cart = ShoppingCartBLL.GetCart(this.HttpContext); var shoppingCart = new ShoppingCart { CartItems = cart.GetCartItems(), CartTotal = cart.GetTotal() }; ViewBag.Cart = shoppingCart; return View(model); }
public void PopulateInProgressOrdersGridView() { int workerID = Convert.ToInt32(Session["WorkerID"]); OrderService os = new OrderService(); this.GridViewInProgressOrders.DataSource = os.GetOrdersInProgressForWorker(workerID); this.GridViewInProgressOrders.DataBind(); }
protected void stateSearchButton_Click(object sender, EventArgs e) { var svc = new OrderService(); var sb = new StringBuilder(); var list = svc.GetCustomersByState(stateSearchTextBox.Text); sb.Append(@" <table> <tr> <th>Customer ID</th> <th>First Name</th> <th>STate</th> </tr> "); foreach (var c in list) { sb.Append("<tr>"); sb.AppendFormat("<td>{0}</td>", c.CustomerID); sb.AppendFormat("<td>{0}</td>", c.FirstName); sb.AppendFormat("<td>{0}</td>", c.State); sb.Append("</tr>"); } sb.Append(@" </table> "); stateSearchResultLabel.Text = sb.ToString(); }
public void PopulateInProgressOrdersGridView() { OrderService os = new OrderService(); int clientID = Convert.ToInt32(Session["UserID"]); this.GridViewInProgressOrders.DataSource = os.GetClientOrders(clientID); this.GridViewInProgressOrders.DataBind(); }
public String GetTableOrderDate(Int32 tableId) { OrderService service = new OrderService(); TableOrder tableOrder = service.GetTableOrder(tableId); if (tableOrder != default(TableOrder)) { return String.Format("{0:M/d/yyyy HH:mm:ss}", tableOrder.DateModified); } return String.Format("{0:M/d/yyyy HH:mm:ss}", DateTime.Now); }
public TableOrder GetTableOrder(Int32 tableId) { OrderService service = new OrderService(); TableOrder tableOrder = service.GetTableOrder(tableId); if (tableOrder != default(TableOrder)) { return tableOrder; } return null; }
public Int32 GetTableOrderStatus(Int32 tableId) { OrderService service = new OrderService(); TableOrder tableOrder = service.GetTableOrder(tableId); if (tableOrder != default(TableOrder)) { return tableOrder.Status; } return (Int32)Common.TableOrderStatus.Closed; }
public void Init() { TestUtils utils = new TestUtils(); orderService = (OrderService) user.GetService(DfpService.v201511.OrderService); advertiserId = utils.CreateCompany(user, CompanyType.ADVERTISER).id; salespersonId = utils.GetSalesperson(user).id; traffickerId = utils.GetTrafficker(user).id; orderId = utils.CreateOrder(user, advertiserId, salespersonId, traffickerId).id; }
public void Is_invalid_when_associated_orders_exist() { var customerID = 1; var orderDataProxy = new Mock<IOrderDataProxy>(); orderDataProxy.Setup(p => p.GetByCustomer(customerID)).Returns(Enumerable.OfType<Order>(new[] { new Order() })); var orderService = new OrderService(orderDataProxy.Object, Mock.Of<IOrderItemService>(), Mock.Of<ITransactionContext>()); var rule = new CanDeleteCustomerRule(customerID, orderService); rule.Validate().IsValid.ShouldBe(false); rule.ErrorMessage.ShouldNotBe(null); }
public void Is_valid_when_no_associated_orders_exist() { var productID = 1; var orderDataProxy = new Mock<IOrderDataProxy>(); orderDataProxy.Setup(p => p.GetByProduct(productID)).Returns(Enumerable.Empty<Order>()); var orderService = new OrderService(orderDataProxy.Object, Mock.Of<IOrderItemService>(), Mock.Of<ITransactionContext>()); var rule = new CanDeleteProductRule(productID, orderService); rule.Validate().IsValid.ShouldBe(true); rule.ErrorMessage.ShouldBe(null); }
public OrderVM(OrderInfo order, OrderService orderService) { ID = order.OrderID; OrderDate = order.OrderDate; Customer = order.CustomerName; CustomerID = order.CustomerID; Total = order.Total; Status = order.Status; HasShippedItems = order.HasShippedItems; _orderService = orderService; }
public OrderVM(CustomerOrderVM order, MainWindowVM vm, OrderService orderService) { ID = order.ID; OrderDate = order.CurrentEntity.OrderDate; Customer = vm.CustomersVM.Customers.First(c => c.ID == order.CurrentCustomerID).Name; CustomerID = order.CurrentCustomerID; Total = order.OrderItems.Sum(i => i.Amount.Value); Status = order.Status == null ? string.Empty : order.Status.Name; HasShippedItems = order.OrderItems.Any(i => i.Status is ShippedState); _orderService = orderService; }
public CustomerOrderWindow(OrderService orderService, CustomerService customerService, OrderItemService orderItemService, InventoryItemService inventoryService, MainWindowVM mainVM, EventAggregator eventAggregator) : this() { var vm = new CustomerOrderVM(eventAggregator, orderService, orderItemService, inventoryService, mainVM); DataContext = vm; }
public DeleteProductCommand(long productID, IProductDataProxy productDataProxy, InventoryItemService inventoryService, OrderService orderService, ITransactionContext transactionContext) { _productID = productID; _productDataProxy = productDataProxy; _inventoryService = inventoryService; _orderService = orderService; _transactionContext = transactionContext; }
public async Task Is_valid_when_no_associated_orders_exist_async() { var customerID = 1; var orderDataProxy = new Mock<IOrderDataProxy>(); orderDataProxy.Setup(p => p.GetByCustomerAsync(customerID)) .Returns(Task.FromResult(Enumerable.Empty<Order>())); var orderService = new OrderService(orderDataProxy.Object, Mock.Of<IOrderItemService>(), Mock.Of<ITransactionContext>()); var rule = new CanDeleteCustomerRule(customerID, orderService); await rule.ValidateAsync(); rule.IsValid.ShouldBe(true); rule.ErrorMessage.ShouldBe(null); }
public async Task Is_invalid_when_associated_orders_exist_async() { var productID = 1; var orderDataProxy = new Mock<IOrderDataProxy>(); orderDataProxy.Setup(p => p.GetByProductAsync(productID)) .Returns(Task.FromResult(Enumerable.OfType<Order>(new[] { new Order() }))); var orderService = new OrderService(orderDataProxy.Object, Mock.Of<IOrderItemService>(), Mock.Of<ITransactionContext>()); var rule = new CanDeleteProductRule(productID, orderService); await rule.ValidateAsync(); rule.IsValid.ShouldBe(false); rule.ErrorMessage.ShouldNotBe(null); }
public void RetrieveOrderServiceTest() { Order order = ObjectMother.GetOrder(); var repositoryFake = new Mock<IOrderRepository>(); repositoryFake.Setup(r => r.Get(1)).Returns(order); IOrderService service = new OrderService(repositoryFake.Object); var orderFake = service.Retrieve(1); repositoryFake.Verify(r => r.Get(1)); Assert.IsNotNull(orderFake); }
public void DeleteOrderServiceTest() { Order order = null; var repositoryFake = new Mock<IOrderRepository>(); repositoryFake.Setup(r => r.Delete(1)).Returns(order); IOrderService service = new OrderService(repositoryFake.Object); var orderFake = service.Delete(1); repositoryFake.Verify(r => r.Delete(1)); Assert.IsNull(orderFake); }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { var productsDataProxy = new ProductRepository(); var inventoryDataProxy = new InventoryItemRepository(); var customerDataProxy = new CustomerRepository(); var orderItemDataProxy = new OrderItemRepository(); var orderRepository = new OrderRepository(customerDataProxy, orderItemDataProxy); _inventoryService = new InventoryItemService(inventoryDataProxy); _orderItemsService = new OrderItemService(orderItemDataProxy, productsDataProxy, inventoryDataProxy, new DTCTransactionContext()); _ordersService = new OrderService(orderRepository, _orderItemsService, new DTCTransactionContext()); _customersService = new CustomerService(customerDataProxy, _ordersService); _productsService = new ProductService(productsDataProxy, _ordersService, _inventoryService, new DTCTransactionContext()); _categoriesService = new CategoryService(new CategoryRepository(), _productsService); this.DataContext = new MainWindowVM(_eventAggregator, _customersService, _productsService, _categoriesService, _ordersService, _inventoryService); }
private void ConfigureEFUsage() { var productsDataProxy = new DAL.EF.ProductRepository(); var inventoryDataProxy = new DAL.EF.InventoryItemRepository(); var customerDataProxy = new DAL.EF.CustomerRepository(); var orderItemDataProxy = new DAL.EF.OrderItemRepository(); var orderRepository = new DAL.EF.OrderRepository(); var categoriesDataProxy = new DAL.EF.CategoryRepository(); _inventoryService = new InventoryItemService(inventoryDataProxy); _orderItemsService = new OrderItemService(orderItemDataProxy, productsDataProxy, inventoryDataProxy, new DTCTransactionContext()); _ordersService = new OrderService(orderRepository, _orderItemsService, new DTCTransactionContext()); _customersService = new CustomerService(customerDataProxy, _ordersService); _productsService = new ProductService(productsDataProxy, orderRepository, _inventoryService, new DTCTransactionContext()); _categoriesService = new CategoryService(categoriesDataProxy, productsDataProxy); this.DataContext = new MainWindowVM(_eventAggregator, _customersService, _productsService, _categoriesService, _ordersService, _inventoryService); }
public void Test_PostOrder_StartOrderService_NoOrder() { // var abaService = MockRepository.GenerateMock<IAbacusService>(); // var orderService = new OrderService(abacusService: abaService); abaService.Replay(); //reply orderService.StartOrderService(); //由于是基于thread的。我们故意在这里等 System.Threading.Thread.Sleep(5000);//5s abaService.AssertWasNotCalled(p => p.SendPassenger("ylshan@com")); }
public void UpdateOrderServiceValidationAndPersistenceTest() { Order order = ObjectMother.GetOrder(); var repositoryFake = new Mock<IOrderRepository>(); repositoryFake.Setup(r => r.Update(order)).Returns(order); var orderFake = new Mock<Order>(); orderFake.As<IObjectValidation>().Setup(b => b.Validate()); IOrderService service = new OrderService(repositoryFake.Object); service.Update(orderFake.Object); orderFake.As<IObjectValidation>().Verify(b => b.Validate()); repositoryFake.Verify(r => r.Update(orderFake.Object)); }
protected void Button1_Click(object sender, EventArgs e) { Order NewOrder = new Order(); //פרטי ההזמנה NewOrder.CustomerID = TextBox1.Text; NewOrder.RequiredDate = DateTime.Now; NewOrder.OrderProductds = (ShoppingBag)Session["mShoppingBag"]; try { OrderService service = new OrderService(); Label1.Text = service.CreateOrder(NewOrder).ToString(); } catch (Exception ex) { Label1.Text = ex.Message; } }
public MainWindowVM(EventAggregator eventAggregator, CustomerService customerService, ProductService productService, CategoryService categoryService, OrderService orderService, InventoryItemService inventoryService) { _customersVM = new CustomersVM(customerService); _customersVM.LoadCustomersCommand.Execute(null); _productsVM = new ProductsVM(productService, this); _productsVM.LoadProductsCommand.Execute(null); _categoriesVM = new CategoriesVM(categoryService); _categoriesVM.LoadCategoriesCommand.Execute(null); _ordersVM = new OrdersVM(orderService, this, eventAggregator); _ordersVM.LoadOrdersCommand.Execute(null); _inventoryItemsVM = new InventoryItemsVM(inventoryService, this); _inventoryItemsVM.LoadInventoryCommand.Execute(null); }
public void Test_PostOrder_CanQTE() { //用来模拟返回的接口数据 var qteService = MockRepository.GenerateStrictMock<IQTE>(); //这个用于判断接受 var emailService = MockRepository.GenerateStrictMock<IEmailService>(); emailService.Expect(p => p.SendMain(Arg.Text.Contains("recieved"))); qteService.Expect(p => p.QTE(null)).Return(true); //我们调用某个方法来进行返回我们需要的值 qteService.Replay(); OrderService orderService = new OrderService(qteService, emailService); orderService.PostOrder(12); qteService.AssertWasCalled(p => p.QTE(null)); emailService.AssertWasCalled(p => p.SendMain(Arg<string>.Is.Anything)); }
public CustomerOrderWindow(OrderVM currentOrder, OrderService orderService, CustomerService customerService, OrderItemService orderItemService, InventoryItemService inventoryService, MainWindowVM mainVM, EventAggregator eventAggregator) : this() { var order = new Order() { ID = currentOrder.ID, CustomerID = currentOrder.CustomerID, OrderDate = currentOrder.OrderDate, }; var vm = new CustomerOrderVM(eventAggregator, order, orderService, orderItemService, inventoryService, mainVM); vm.RefreshCommand.Execute(null); DataContext = vm; }
protected void Page_Load(object sender, EventArgs e) { // 1. Csinál egy orderRepository-t (A Web.config-ban lévő ShopConnectionString- segítségével.) IOrderRepository orderRepository = new OrderRepository(ConfigurationManager.ConnectionStrings["ShopConnectionString"].ConnectionString); // 2. Amit az OrderService -osztály használ majd az adatbázissal való közvetlen kommunikációra. OrderService orderService = new OrderService(orderRepository); IEnumerable<Order> orders; Guid customerId = new Guid("be948490-dbdc-4d55-b4a1-0ad52ec72b39"); // 3. Itt az OrderService egy metódusa lekérdez az adatbázisból a következő módon : 4.pont orders = orderService.FindAllCustomersOrdersBy(customerId); // 13. És kész a kiolvasás.... :-) foreach (Order order in orders) { Response.Write(order.OrderDate + "<br/>"); } Response.Write("<br/><br/>"); orders = orderService.FindAllCustomersOrdersWithInOrderDateBy(customerId, DateTime.Parse("06/03/2010 23:59:59")); foreach (Order order in orders) { Response.Write(order.OrderDate + "<br/>"); } Response.Write("<br/><br/>"); orders = orderService.FindAllCustomersOrdersUsingAComplexQueryWith(customerId); foreach (Order order in orders) { Response.Write(order.OrderDate + "<br/>"); } }
protected void ok_Click(object sender, EventArgs e) { int i = 0, k; int j = 1;//药品是1 手术是2 检查是3 string[] patient_num = new string[] { patient_num1.Text, patient_num2.Text, patient_num3.Text, patient_num4.Text, patient_num5.Text, patient_num6.Text, patient_num7.Text, patient_num8.Text, patient_num9.Text, patient_num10.Text }; string[] examination = new string[] { examination1.Text, examination2.Text, examination3.Text, examination4.Text, examination5.Text, examination6.Text, examination7.Text, examination8.Text, examination9.Text, examination10.Text }; string[] examination_num = new string[] { examination_num1.Text, examination_num2.Text, examination_num3.Text, examination_num4.Text, examination_num5.Text, examination_num6.Text, examination_num7.Text, examination_num8.Text, examination_num9.Text, examination_num10.Text }; string[] doctor = new string[] { doctor1.Text, doctor2.Text, doctor3.Text, doctor4.Text, doctor5.Text, doctor6.Text, doctor7.Text, doctor8.Text, doctor9.Text, doctor10.Text }; string[] order = new string[] { order1.Text, order2.Text, order3.Text, order4.Text, order5.Text, order6.Text, order7.Text, order8.Text, order9.Text, order10.Text }; int rowCount = 0; for (rowCount = 0; rowCount < 10; rowCount++) { if (patient_num[rowCount] == "") { break; } else { //先判断有没有空格 if (examination[rowCount].Equals("") || doctor[rowCount].Equals("") || order[rowCount].Equals("") || examination_num.Equals("")) { Response.Write("<script language=javascript>window.alert('输入有空格!');</script>"); } //如果没有空格,可以检查主键是否冲突 else { /* if(OrderService.JudgeOrderDuplicate(order [rowCount])==-1)//-1有冲突 * { * i = 1;break; * } * else * { * i = 0;//没冲突 * }*/ OrderService.AddOrder(patient_num[rowCount], examination_num[rowCount], int.Parse(examination[rowCount]), doctor[rowCount], order[rowCount], j); patient_num1.Text = ""; patient_num2.Text = ""; patient_num3.Text = ""; patient_num4.Text = ""; patient_num5.Text = ""; patient_num6.Text = ""; patient_num7.Text = ""; patient_num8.Text = ""; patient_num9.Text = ""; patient_num10.Text = ""; examination1.Text = ""; examination2.Text = ""; examination3.Text = ""; examination4.Text = ""; examination5.Text = ""; examination6.Text = ""; examination7.Text = ""; examination8.Text = ""; examination9.Text = ""; examination10.Text = ""; doctor1.Text = ""; doctor2.Text = ""; doctor3.Text = ""; doctor4.Text = ""; doctor5.Text = ""; doctor6.Text = ""; doctor7.Text = ""; doctor8.Text = ""; doctor9.Text = ""; doctor10.Text = ""; order1.Text = ""; order2.Text = ""; order3.Text = ""; order4.Text = ""; order5.Text = ""; order6.Text = ""; order7.Text = ""; order8.Text = ""; order9.Text = ""; order10.Text = ""; } } } /*if(i==1) * { * Response.Write("<script language=javascript>window.alert('当前输入订单编号已存在,请重新检查!');</script>"); * } * else * { * for(k=0;k<10;k++) * { * OrderService.AddOrder(patient_num[k], examination_num[k], int.Parse(examination[k]), doctor[k], order[k], j, time[k]); * patient_num1.Text = ""; patient_num2.Text = ""; patient_num3.Text = ""; patient_num4.Text = ""; patient_num5.Text = ""; patient_num6.Text = ""; patient_num7.Text = ""; patient_num8.Text = ""; patient_num9.Text = ""; patient_num10.Text = ""; * examination1.Text = ""; examination2.Text = ""; examination3.Text = ""; examination4.Text = ""; examination5.Text = ""; examination6.Text = ""; examination7.Text = ""; examination8.Text = ""; examination9.Text = ""; examination10.Text = ""; * examination_num1.Text = ""; examination_num2.Text = ""; examination_num3.Text = ""; examination_num4.Text = ""; examination_num5.Text = ""; examination_num6.Text = ""; examination_num7.Text = ""; examination_num8.Text = ""; examination_num9.Text = ""; examination_num10.Text = ""; * doctor1.Text = ""; doctor2.Text = ""; doctor3.Text = ""; doctor4.Text = ""; doctor5.Text = ""; doctor6.Text = ""; doctor7.Text = ""; doctor8.Text = ""; doctor9.Text = ""; doctor10.Text = ""; * order1.Text = ""; order2.Text = ""; order3.Text = ""; order4.Text = ""; order5.Text = ""; order6.Text = ""; order7.Text = ""; order8.Text = ""; order9.Text = ""; order10.Text = ""; * time1.Text = ""; time2.Text = ""; time3.Text = ""; time4.Text = ""; time5.Text = ""; time6.Text = ""; time7.Text = ""; time8.Text = ""; time9.Text = ""; time10.Text = ""; * } * }*/ //清空数据 }
public void Test_Given_Cart_Contains_Product_ToCheckout_New_Order_Can_Be_Saved_To_Database_ShouldUpdateStockInProductsTable() { //Arrange var options = TestDbContextOptionsBuilder(); SeedTestDb(options); //This product should exist in the Products table (It is added as part of initial data seed) var productPurchased = new Product() { Id = 2, Description = "test desc 2", Details = "test details 2", Name = "test product 2", Price = 20.10, Quantity = 200 }; //Prepare the order to add var orderToAdd = new OrderViewModel() { Name = "new order", Address = "new address", City = "new City", Zip = "new zip", Country = "new country", Lines = new List <CartLine>() { new CartLine() { Product = productPurchased, Quantity = 10 } } }; using (var context = new P3Referential(options)) { var cart = new Cart(); //Add the item to the cart cart.AddItem(productPurchased, 10); var productRepository = new ProductRepository(context); var orderRepository = new OrderRepository(context); var productService = new ProductService(cart, productRepository, null, null); var orderService = new OrderService(cart, orderRepository, productService); // Act orderService.SaveOrder(orderToAdd); } //Assert using (var context = new P3Referential(options)) { var savedOrders = context.Order.Include(x => x.OrderLine).ToList(); Assert.Equal(_testOrdersList.Count + 1, savedOrders.Count); Assert.IsAssignableFrom <List <Order> >(savedOrders); //get the most recent order which is just newly added (2 were pre-existing) var savedOrder = savedOrders.Find(x => x.Id == 3); //get the orderLine of order passed in for adding var orderToAddFirstLine = orderToAdd.Lines.First(x => x.Product.Id == 2); //get the orderLine of actual saved var savedOrderFirstLine = savedOrder.OrderLine.First(x => x.ProductId == 2); var doesDataMatch = orderToAdd.Address == savedOrder.Address && orderToAdd.City == savedOrder.City && orderToAdd.Country == savedOrder.Country && orderToAdd.Lines.Count == savedOrder.OrderLine.Count && orderToAddFirstLine.Product.Id == savedOrderFirstLine.ProductId && orderToAddFirstLine.Quantity == savedOrderFirstLine.Quantity; Assert.True(doesDataMatch); //Check if product stock is reduced after the order Assert.Equal(200 - 10, context.Product.ToList().Find(x => x.Id == 2).Quantity); //Cleanup context.Database.EnsureDeleted(); } }
public OrdersController(OrderService OrderService) { _OrderService = OrderService; }
public OrderController() { _catalogService = new CatalogService(); _orderService = new OrderService(); }
public ToursViewModel(PageService pageservice, ToursService toursService, OrderService orderService) : base(pageservice) { this.toursService = toursService; this.orderService = orderService; Init(); }
public OrderServiceTest() { iRepositoryFake = Substitute.For <IOrderRepository>(); sut = new OrderService(iRepositoryFake); }
public void CanCheckoutAndCreateOrder() { IRepository <Product> products = new MockContext <Product>(); IRepository <Customer> customers = new MockContext <Customer>(); products.Insert(new Product() { Id = "1", Price = 10.00m }); products.Insert(new Product() { Id = "2", Price = 5.00m }); IRepository <Basket> baskets = new MockContext <Basket>(); Basket basket = new Basket(); basket.BasketItems.Add(new BasketItem() { ProductId = "1", Quantity = 2, BasketId = basket.Id }); basket.BasketItems.Add(new BasketItem() { ProductId = "2", Quantity = 1, BasketId = basket.Id }); baskets.Insert(basket); IBasketService basketService = new BasketServices(products, baskets); IRepository <Order> orders = new MockContext <Order>(); IOrderService orderService = new OrderService(orders); customers.Insert(new Customer() { Id = "1", Email = "*****@*****.**", ZipCode = "11111" }); IPrincipal FakeUser = new GenericPrincipal(new GenericIdentity("*****@*****.**", "Forms"), null); var controller = new BasketController(basketService, orderService, customers); var httpContext = new MockHttpContext(); httpContext.User = FakeUser; httpContext.Request.Cookies.Add(new System.Web.HttpCookie("eCommerceBasket") { Value = basket.Id }); controller.ControllerContext = new System.Web.Mvc.ControllerContext(httpContext, new System.Web.Routing.RouteData(), controller); //Run Order order = new Order(); controller.Checkout(order); //assert Assert.AreEqual(2, order.OrderItems.Count); Assert.AreEqual(0, basket.BasketItems.Count); Order orderInRep = orders.Find(order.Id); Assert.AreEqual(2, orderInRep.OrderItems.Count); }
/// <summary> /// Handles any unspecified OnPot requests from user. /// </summary> public void OnPost() { targetUrlRegisterClient = "http://localhost:8080/server_war_exploded/root/api/registerclient"; orderService = new OrderService(); Task <string> response = orderService.PostRegisterClientAsync(Client, targetUrlRegisterClient); }
// GET: Order public ActionResult Index() { OrderService.GetOrders(); return(View()); }
protected void btnPrint_Click(object sender, EventArgs e) { List <STORE> list = new List <STORE>(); var cmd = new StoreService(); for (int i = 0; i < grideInOrder.Rows.Count; i++) { if (list.Where(x => x.STORE_ID == Convert.ToInt32(grideInOrder.DataKeys[i].Values[1].ToString())).FirstOrDefault() == null) { list.Add(cmd.Select(Convert.ToInt32(grideInOrder.DataKeys[i].Values[1].ToString()))); } } List <InOrderForPrint> listInOrder = new List <InOrderForPrint>(); var cmdOrder = new OrderService(); var cmdOrderDetail = new OrderDetailService(); List <ORDER> tmpListOrder = new List <ORDER>(); foreach (STORE tmp in list) { InOrderForPrint inOrder = new InOrderForPrint(); inOrder.Store = tmp; inOrder.OrderDetails = new List <ORDER_DETAIL>(); tmpListOrder = cmdOrder.GetALLIncludeByStore(tmp.STORE_ID); foreach (ORDER tmpOrder in tmpListOrder) { inOrder.Order = tmpOrder; inOrder.OrderDetails.AddRange(cmdOrderDetail.GetALLIncludeByOrder(tmpOrder.ORDER_ID).ToList()); } listInOrder.Add(inOrder); } InOrderReportData ds = new InOrderReportData(); DataTable dt = ds.Tables["Data"]; DataTable dt2 = ds.Tables["Data2"]; List <ListOfLineForPrint> lstHead = new List <ListOfLineForPrint>(); foreach (InOrderForPrint item in listInOrder) { List <LineForPrint> lstLine = new List <LineForPrint>(); ListOfLineForPrint tmpList = new ListOfLineForPrint(); tmpList.LineForPrint = new List <LineForPrint>(); LineForPrint linePrint = new LineForPrint(); linePrint.line1 = ConvertDateToThai(item.Order.ORDER_DATE.Value); if (item.Store.PROVINCE_ID == 1) { linePrint.line2 = item.Store.STORE_NAME + " (" + item.Store.STORE_CODE.Substring(item.Store.STORE_CODE.Length - 3, 3) + " )"; } else { linePrint.line2 = item.Store.STORE_CODE + " " + item.Store.STORE_NAME; } linePrint.line3 = "จำนวน"; linePrint.line4 = ""; linePrint.line5 = "ราคาต่อชิ้น"; lstLine.Add(linePrint); foreach (ORDER_DETAIL od in item.OrderDetails) { LineForPrint linePrintItem = new LineForPrint(); linePrintItem.line1 = ""; if (od.IS_FREE.Value) { linePrintItem.line2 = "แถม"; } else { linePrintItem.line2 = od.PRODUCT.PRODUCT_NAME; } linePrintItem.line3 = od.PRODUCT_QTY.ToString(); linePrintItem.line4 = ""; linePrintItem.line5 = od.PRODUCT_PRICE.ToString(); lstLine.Add(linePrintItem); } tmpList.LineForPrint.AddRange(lstLine); lstHead.Add(tmpList); } DataRow dr1; int indexData1 = 0; for (int i = 0; i < lstHead.Count; i++) { for (int j = 0; j < lstHead[i].LineForPrint.Count; j++) { dr1 = dt.NewRow(); dr1["LINEX"] = indexData1++; dr1["LINE1"] = lstHead[i].LineForPrint[j].line1; dr1["LINE2"] = lstHead[i].LineForPrint[j].line2; dr1["LINE3"] = lstHead[i].LineForPrint[j].line3; dr1["LINE4"] = lstHead[i].LineForPrint[j].line4; dr1["LINE5"] = lstHead[i].LineForPrint[j].line5; dt.Rows.Add(dr1); } for (int k = 0; k < 5; k++) { dr1 = dt.NewRow(); dr1["LINEX"] = indexData1++; dr1["LINE1"] = ""; dr1["LINE2"] = ""; dr1["LINE3"] = ""; dr1["LINE4"] = ""; dr1["LINE5"] = ""; dt.Rows.Add(dr1); } } Session["DataToReport"] = ds; Response.Redirect("../Reports/InOrder.aspx"); }
/// <summary> /// (-) 點菜單動作 /// </summary> private void OrderMeal() { _Statue = "OrderMeal"; //定義接收CIC結果的類別 ProcessResult <Models.LineConversation.Order_C.Order_Request> result; OrderService service = new OrderService(_LineEvent.source.userId); var CIC = service.GetConversationCIC(_ChannelAccessToken); if (_LineEvent.message.text == "OrderMeal") { ///開始點餐程序 //把訊息丟給CIC result = CIC.Process(_SendData.events.FirstOrDefault(), true); } else { //把訊息丟給CIC result = CIC.Process(_LineEvent); } //isRock.LineBot.TextMessage textMsg = new isRock.LineBot.TextMessage(result.ResponseMessageCandidate); _TextMessage = new isRock.LineBot.TextMessage(result.ResponseMessageCandidate);; //處理 CIC回覆的結果 switch (result.ProcessResultStatus) { case ProcessResultStatus.Processed: ///繼續對話 service.QuickReply_Order(_TextMessage); //_Bot.PushMessage(_LineEvent.source.userId, _TextMessage); return; case ProcessResultStatus.Done: ///完成對話 service.AddOrder(Newtonsoft.Json.JsonConvert.SerializeObject(result.ConversationState.ConversationEntity)); _ReplyMessage = "完成訂單!!"; _Statue = string.Empty; return; case ProcessResultStatus.Pass: ///目前不再對話狀態中,非典餐過程 _Statue = string.Empty; break; case ProcessResultStatus.Exception: ///取得候選訊息發送,例外 _ReplyMessage += result.ResponseMessageCandidate; break; case ProcessResultStatus.Break: ///離開對話 ///responseMsg += result.ResponseMessageCandidate; _ReplyMessage = "中止點餐"; _Statue = string.Empty; return; case ProcessResultStatus.InputDataFitError: ///內容轉型失敗 ///可以判斷狀態再重新計一次QuickReply service.QuickReply_Order(_TextMessage); return; default: //取得候選訊息發送 _ReplyMessage += result.ResponseMessageCandidate; break; } }
public void CanCheckOutAndCreateOrder() { ////Setup IRepository <Product> products = new MockContext <Product>(); //Mock product repository created IRepository <Customer> customers = new MockContext <Customer>(); //Creating MockContect repository for Customer (linking customers to orders process) //Adding some basic information in repository //Added Id and Price because that's the only thing that will affect any of calculations products.Insert(new Product() { Id = "1", Price = 10.00m }); products.Insert(new Product() { Id = "2", Price = 8.00m }); products.Insert(new Product() { Id = "3", Price = 13.00m }); IRepository <Cart> carts = new MockContext <Cart>(); //Creating Mock Cart repository Cart cart = new Cart(); //New underlying Cart //Adding some basic information cart.CartItems.Add(new CartItem() { ProductId = "1", Quanity = 2, CartId = cart.Id }); cart.CartItems.Add(new CartItem() { ProductId = "1", Quanity = 1, CartId = cart.Id }); cart.CartItems.Add(new CartItem() { ProductId = "1", Quanity = 3, CartId = cart.Id }); //I need to add that cart to the cart repository carts.Insert(cart); //Creating CartService ICartService cartService = new CartService(products, carts); //Creating OrderService first I need again repository of order IRepository <Order> orders = new MockContext <Order>(); IOrderService orderService = new OrderService(orders); //if I wanted to test the order service directly. I could simply act on the order service itself. //but I am going to test controller again ////Adding FakeUser(linking customers to orders process) customers.Insert(new Customer() { Id = "1", Email = "*****@*****.**", ZipCode = "02129" }); ////Creating IPrincipal //built in class called GenericPrincipal takes in GenericIdentity that simply wants an email adress.(linking customers to orders process) //I Also need to tell it the type of authentication is Forms authentication(linking customers to orders process) //I used null here because when I create our generic principle it wants to know what roles it has(linking customers to orders process) //I am not using roles that can simply be null(linking customers to orders process) IPrincipal FakeUser = new GenericPrincipal(new GenericIdentity("*****@*****.**", "Forms"), null); //Adding additional information into create a CartController instance var controller = new CartController(cartService, orderService, customers); //controller expect cartService and OrderService //Adding customers (linking customers to orders process) var httpContext = new MockHttpContext(); //Injecting fake context so that it can read an write cookies //Creating cookie itself manually because i am creating cart manually httpContext.Request.Cookies.Add(new System.Web.HttpCookie("eCommerceCart") { Value = cart.Id }); httpContext.User = FakeUser;////Adding FakeUser(linking customers to orders process) //As last one I need to add httpContext to the underlying ControllerContext controller.ControllerContext = new ControllerContext(httpContext, new System.Web.Routing.RouteData(), controller); ////Act Order order = new Order();//creating order controller.CheckOut(order); ////Assert Assert.AreEqual(3, order.OrderItems.Count); //testing order items Assert.AreEqual(0, cart.CartItems.Count); //Make sure I have created an order and I want to clear the cart down Order orderInRep = orders.Find(order.Id); //try and retrieve the order from the repository. Assert.AreEqual(3, orderInRep.OrderItems.Count); //check 3 order items in the repository itself }
private bool saveData() { calculateTotal(); if (validator1.Validate() && ValidateData()) { if (cbxCustomer.SelectedValue == null || cbxCustomer.SelectedIndex <= 0) { MessageBox.Show("Bạn cần có một khách hàng cho phiếu này!"); return false; } DialogResult dialogResult = Preview(); if (dialogResult == DialogResult.OK) { XKNumber = PrintPreview.XKNumber; BHNumber = PrintPreview.BHNumber; double discount = 0; Double.TryParse(txtDiscount.WorkingText, out discount); DateTime createdDate = BaoHienRepository.GetBaoHienDBDataContext().GetSystemDate(); double vat = 0; Double.TryParse(txtVAT.WorkingText, out vat); int userId = 0; if (Global.CurrentUser != null) { userId = Global.CurrentUser.Id; } else { MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } if (order != null)//update { #region Update order.CustId = (int)cbxCustomer.SelectedValue; order.Discount = discount; order.Note = txtNote.Text; order.VAT = vat; order.OrderCode = txtOrderCode.Text; order.Reason = txtReason.Text; order.WareHouse = txtWare.Text; order.Total = totalWithTax; order.UpdatedDate = createdDate; #region Update Order Detail string msg = ""; int error = 0, amount_change = 0; ProductLog pl, newpl; OrderDetail prd; // Check old data OrderDetailService orderDetailService = new OrderDetailService(); List<OrderDetail> deleted_details = old_orderDetails.Where(x => !orderDetails.Select(y => y.ProductId.ToString() + '_' + y.AttributeId.ToString() + '_' + y.UnitId.ToString()).Contains(x.ProductId.ToString() + '_' + x.AttributeId.ToString() + '_' + x.UnitId.ToString())).ToList(); List<OrderDetail> updated_details = old_orderDetails.Where(x => orderDetails.Select(y => y.ProductId.ToString() + '_' + y.AttributeId.ToString() + '_' + y.UnitId.ToString()).Contains(x.ProductId.ToString() + '_' + x.AttributeId.ToString() + '_' + x.UnitId.ToString())).ToList(); List<OrderDetail> new_details = orderDetails.Where(x => !old_orderDetails.Select(y => y.ProductId.ToString() + '_' + y.AttributeId.ToString() + '_' + y.UnitId.ToString()).Contains(x.ProductId.ToString() + '_' + x.AttributeId.ToString() + '_' + x.UnitId.ToString())).ToList(); foreach (OrderDetail item in updated_details) { pl = productLogService.GetProductLog(item.ProductId, item.AttributeId, item.UnitId); prd = orderDetails.Where(x => x.ProductId == item.ProductId && x.AttributeId == item.AttributeId && x.UnitId == item.UnitId).FirstOrDefault(); amount_change = Convert.ToInt32(prd.NumberUnit - item.NumberUnit); if (amount_change > 0 && pl.AfterNumber - amount_change < 0) // Tang nguyen lieu { if (error == 0) { msg += "Những sản phẩm sau đã bị SỬA nhưng không đảm bảo dữ liệu trong kho:\n"; error = 1; } msg += "- " + productLogService.GetNameOfProductLog(pl) + " : " + amount_change.ToString() + "\n"; } } foreach (OrderDetail item in new_details) { pl = productLogService.GetProductLog(item.ProductId, item.AttributeId, item.UnitId); if (pl.AfterNumber - item.NumberUnit < 0) { if (error < 2) { msg += "Những sản phẩm sau không đủ số lượng để tạo phiếu bán hàng:\n"; error = 2; } msg += "- " + productLogService.GetNameOfProductLog(pl) + " còn : " + pl.AfterNumber + "\n"; } } if (error > 0) { MessageBox.Show(msg, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } foreach (OrderDetail item in deleted_details) { pl = productLogService.GetProductLog(item.ProductId, item.AttributeId, item.UnitId); newpl = new ProductLog() { ProductId = item.ProductId, AttributeId = item.AttributeId, UnitId = item.UnitId, BeforeNumber = pl.AfterNumber, Amount = item.NumberUnit, AfterNumber = pl.AfterNumber + item.NumberUnit, RecordCode = order.OrderCode, Status = BHConstant.ACTIVE_STATUS, Direction = BHConstant.DIRECTION_IN, UpdatedDate = createdDate }; productLogService.AddProductLog(newpl); } foreach (OrderDetail od in orderDetails) { od.OrderId = order.Id; if (od.ProductId > 0 && od.AttributeId > 0 && od.UnitId > 0) { totalCommission += od.Commission; OrderDetail tmp_ode = old_orderDetails.Where(x => x.ProductId == od.ProductId && x.AttributeId == od.AttributeId && x.UnitId == od.UnitId && x.OrderId == order.Id).FirstOrDefault(); if (tmp_ode != null) { double amount = tmp_ode.NumberUnit - od.NumberUnit; bool ret = orderDetailService.UpdateOrderDetail(od); //Save in Production Log if (amount != 0) { pl = productLogService.GetProductLog(od.ProductId, od.AttributeId, od.UnitId); newpl = new ProductLog() { ProductId = od.ProductId, AttributeId = od.AttributeId, UnitId = od.UnitId, BeforeNumber = pl.AfterNumber, Amount = Math.Abs(amount), AfterNumber = pl.AfterNumber + amount, RecordCode = order.OrderCode, Status = BHConstant.ACTIVE_STATUS, Direction = amount > 0 ? BHConstant.DIRECTION_IN : BHConstant.DIRECTION_OUT, UpdatedDate = createdDate }; productLogService.AddProductLog(newpl); } } else { bool ret = (od.Id != null && od.Id > 0) ? orderDetailService.UpdateOrderDetail(od) : orderDetailService.AddOrderDetail(od); //Save in Production Log pl = productLogService.GetProductLog(od.ProductId, od.AttributeId, od.UnitId); newpl = new ProductLog() { ProductId = od.ProductId, AttributeId = od.AttributeId, UnitId = od.UnitId, BeforeNumber = pl.AfterNumber, Amount = od.NumberUnit, AfterNumber = pl.AfterNumber - od.NumberUnit, RecordCode = order.OrderCode, Status = BHConstant.ACTIVE_STATUS, Direction = BHConstant.DIRECTION_OUT, UpdatedDate = createdDate }; productLogService.AddProductLog(newpl); } } } OrderService orderService = new OrderService(); bool result = orderService.UpdateOrder(order); #endregion #region KH & NV CustomerLogService cls = new CustomerLogService(); CustomerLog newest = cls.GetCustomerLog(order.OrderCode); if (newest != null) { newest.Amount = totalWithTax; cls.UpdateCustomerLog(newest); } int salerId = (int)order.Customer.SalerId; if (salerId > 0) { EmployeeLogService els = new EmployeeLogService(); EmployeeLog order_el = els.SelectEmployeeLogByWhere(x => x.RecordCode == order.OrderCode).FirstOrDefault(); if (order_el != null) { order_el.Amount = totalCommission; els.UpdateEmployeeLog(order_el); } } #endregion if (result) { MessageBox.Show("Phiếu bán hàng đã được cập nhật thành công"); this.Close(); return true; } else { MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } #endregion } else//add new { #region Create New ProductLog pl, newpl; string msg = ""; int error = 0; foreach (OrderDetail item in orderDetails) { pl = productLogService.GetProductLog(item.ProductId, item.AttributeId, item.UnitId); if (pl.AfterNumber - item.NumberUnit < 0) { if (error == 0) { msg += "Những sản phẩm sau không đủ số lượng để tạo phiếu bán hàng:\n"; error = 1; } msg += "- " + productLogService.GetNameOfProductLog(pl) + " còn : " + pl.AfterNumber + "\n"; } } if (error > 0) { MessageBox.Show(msg, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } SeedService ss = new SeedService(); order = new Order { CustId = cbxCustomer.SelectedValue != null ? (int)cbxCustomer.SelectedValue : 0, Discount = discount, Note = txtNote.Text, VAT = vat, OrderCode = ss.AddSeedID(BHConstant.PREFIX_FOR_ORDER), CreatedDate = createdDate, UserId = userId, Reason = txtReason.Text, WareHouse = txtWare.Text, Total = totalWithTax }; OrderService orderService = new OrderService(); bool result = orderService.AddOrder(order); long newOrderId = -1; try { newOrderId = order.Id;// BaoHienRepository.GetMaxId<Order>(); } catch { MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } #region New Order Detail OrderDetailService orderDetailService = new OrderDetailService(); foreach (OrderDetail od in orderDetails) { if (od.ProductId > 0 && od.AttributeId > 0 && od.UnitId > 0) { od.OrderId = (int)newOrderId; bool ret = orderDetailService.AddOrderDetail(od); totalCommission += od.Commission; //Save in Production Log pl = productLogService.GetProductLog(od.ProductId, od.AttributeId, od.UnitId); newpl = new ProductLog() { ProductId = od.ProductId, AttributeId = od.AttributeId, UnitId = od.UnitId, BeforeNumber = pl.AfterNumber, Amount = od.NumberUnit, AfterNumber = pl.AfterNumber - od.NumberUnit, RecordCode = order.OrderCode, Status = BHConstant.ACTIVE_STATUS, Direction = BHConstant.DIRECTION_OUT, UpdatedDate = createdDate }; productLogService.AddProductLog(newpl); } } #endregion #region KH & NV CustomerLogService cls = new CustomerLogService(); CustomerLog cl = new CustomerLog { CustomerId = order.CustId, RecordCode = order.OrderCode, Amount = totalWithTax, Direction = BHConstant.DIRECTION_OUT, CreatedDate = createdDate }; result = cls.AddCustomerLog(cl); int salerId = (int)order.Customer.SalerId; if (salerId > 0) { EmployeeLogService els = new EmployeeLogService(); EmployeeLog newel = new EmployeeLog { EmployeeId = salerId, RecordCode = order.OrderCode, Amount = totalCommission, CreatedDate = createdDate }; result = els.AddEmployeeLog(newel); } #endregion if (result) { MessageBox.Show("Phiếu bán hàng đã được tạo thành công"); this.Close(); return true; } else { MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } #endregion } } return false; } else { MessageBox.Show("Vui lòng kiểm tra các thông tin cần thiết!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } }
public List <Order> GetAllOrders() { return(OrderService.GetAllOrders()); }
public OrderDirectClient(OrderService orderService) { mOrderService = orderService; }
public List <Order> GetOrdersByOrderID(int orderID) { return(OrderService.GetOrderByOrderID(orderID)); }
public OrderTests() { _mocker = new AutoMocker(); _orderService = _mocker.CreateInstance <OrderService>(); }
public ClientRegisterViewModel(PageService pageservice, RegisterService registerService, EventBus eventBus, OrderService orderService) : base(pageservice) { this.registerService = registerService; this.eventBus = eventBus; this.orderService = orderService; Init(); }
public OrderController() { string dbConnection = ConfigurationManager.ConnectionStrings["CourierHelperDb"].ConnectionString; OrderService = new OrderService(dbConnection); }
public AdministratorController(IMapper mapper, CurrentUser currentUser, ProductService productService, OrderService orderService, UserService userService) { _mapper = mapper; _currentUser = currentUser; _productService = productService; _orderService = orderService; _userService = userService; }
public void Init() { // initialize orderService orderService = new OrderService(); orderService.Credentials = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD); orderService.PreAuthenticate = true; orderService.Url = WEBSERVICE_URL; // initialize addresses TAddressNamed Address_in = new TAddressNamed(); Address_in.EMail = "*****@*****.**"; Address_in.FirstName = "Klaus"; Address_in.LastName = "Klaussen"; Address_in.Street = "Musterstraße 2"; Address_in.Street2 = "Ortsteil Niederfingeln"; Address_in.CodePorte = "1234"; TAttribute jobTitle = new TAttribute(); jobTitle.Name = "JobTitle"; jobTitle.Value = "best Job"; TAttribute salutation = new TAttribute(); salutation.Name = "Salutation"; salutation.Value = "Dr."; Address_in.Attributes = new TAttribute[] { jobTitle, salutation }; TAddressNamed Address_up = new TAddressNamed(); Address_up.FirstName = "Hans"; Address_up.LastName = "Hanssen"; Address_up.Street = "Musterstraße 2b"; Address_up.Street2 = "Ortsteil Oberfingeln"; Address_up.CodePorte = "5678"; //initialize order input data Order_in.Alias = alias; Order_in.Customer = customer; Order_in.BillingAddress = Address_in; Order_in.CreationDate = new DateTime(2006, 1, 1, 12, 0, 0, DateTimeKind.Local); Order_in.ViewedOn = new DateTime(2006, 1, 1, 23, 59, 0, DateTimeKind.Local); Order_in.ViewedOnSpecified = true; TAttribute OrderAttr_in = new TAttribute(); OrderAttr_in.Name = "Comment"; OrderAttr_in.Value = "my order comment"; Order_in.Attributes = new TAttribute[] { OrderAttr_in }; TProductLineItemIn Product_in = new TProductLineItemIn(); Product_in.Product = "/Shops/DemoShop/Products/ho_1112105010"; Product_in.Quantity = 10; TLineItemContainerIn lineItemContainer = new TLineItemContainerIn(); lineItemContainer.CurrencyID = "EUR"; lineItemContainer.PaymentMethod = "/Shops/DemoShop/PaymentMethods/Invoice"; lineItemContainer.ShippingMethod = "/Shops/DemoShop/ShippingMethods/Express"; lineItemContainer.TaxArea = "/TaxMatrixGermany/EU"; lineItemContainer.TaxModel = "gross"; lineItemContainer.ProductLineItems = new TProductLineItemIn[] { Product_in }; Order_in.LineItemContainer = lineItemContainer; //initialize order update data Order_up.Path = path; Order_up.BillingAddress = Address_up; Order_up.InProcessOn = new DateTime(2006, 1, 2, 0, 0, 0, DateTimeKind.Local); Order_up.InProcessOnSpecified = true; TAttribute OrderAttr_up = new TAttribute(); OrderAttr_up.Name = "Comment"; OrderAttr_up.Value = "my updated order comment"; Order_up.Attributes = new TAttribute[] { OrderAttr_up }; }
private void DeleteOrder(DataGridViewCellEventArgs e) { DialogResult result = MessageBox.Show("Bạn muốn xóa đơn hàng này?", "Xoá đơn hàng", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { DataGridViewRow currentRow = dgwOrderList.Rows[e.RowIndex]; OrderService orderService = new OrderService(); int id = ObjectHelper.GetValueFromAnonymousType <int>(currentRow.DataBoundItem, "Id"); Order order = orderService.GetOrder(id); DateTime systime = BaoHienRepository.GetBaoHienDBDataContext().GetSystemDate(); #region CustomerLog CustomerLogService cls = new CustomerLogService(); CustomerLog cl = cls.GetCustomerLog(order.OrderCode); bool kq = true; if (cl != null) { kq = cls.DeleteCustomerLog(cl.Id); } #endregion #region ProductLog ProductLogService productLogService = new ProductLogService(); OrderDetailService orderDetailService = new OrderDetailService(); List <OrderDetail> details = orderDetailService.SelectOrderDetailByWhere(x => x.OrderId == order.Id).ToList(); ProductLog pl, newpl; foreach (OrderDetail item in details) { pl = productLogService.GetProductLog(item.ProductId, item.AttributeId, item.UnitId); newpl = new ProductLog() { ProductId = item.ProductId, AttributeId = item.AttributeId, UnitId = item.UnitId, BeforeNumber = pl.AfterNumber, Amount = item.NumberUnit, AfterNumber = pl.AfterNumber + item.NumberUnit, RecordCode = order.OrderCode, Status = BHConstant.DEACTIVE_STATUS, Direction = BHConstant.DIRECTION_IN, UpdatedDate = systime }; productLogService.AddProductLog(newpl); } productLogService.DeactiveProductLog(order.OrderCode); #endregion #region EmployeeLog int salerId = (int)order.Customer.SalerId; if (salerId > 0) { EmployeeLogService els = new EmployeeLogService(); EmployeeLog order_el = els.SelectEmployeeLogByWhere(x => x.RecordCode == order.OrderCode).FirstOrDefault(); if (order_el != null) { els.DeleteEmployeeLog(order_el.Id); } } #endregion if (!orderService.DeleteOrder(id) && kq) { MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } loadOrderList(); } }
public OrderController(OrderService orderService, ParkingLotService parkingLotService) { this.orderService = orderService; this.parkingLotService = parkingLotService; }
public CartController(OrderService orderService, UserManager <User> userManager) { _orderService = orderService; _userManager = userManager; }
public OrdersController(OrderService orderService, ILogger <OrderService> logger, CustomerService customerService) { this.orderService = orderService; this.logger = logger; this.customerService = customerService; }
public CanDeleteCustomerRule(long customerID, OrderService orderService) { _customerID = customerID; _orderService = orderService; }
public HomeController() { _orderService = new OrderService(new OrderRepository(), new FlagLoader()); }
public IHttpActionResult GetPayPage(string orderCode) { LogHelper.WriteLog("GetPayPage " + orderCode); SimpleResult result = new SimpleResult(); IOrderService _orderService = new OrderService(); IProductInfoService _service = new ProductInfoService(); ICouponService _couponService = new CouponService(); string msg = ""; try { if (UserAuthorization) { var orderInfo = _orderService.GetOrderInfo(orderCode); if (orderInfo == null) { msg = "订单不存在!"; result.Status = Result.SYSTEM_ERROR; result.Resource = null; } else if (orderInfo.PayTime != null) { msg = "该订单已付款!"; result.Status = Result.SYSTEM_ERROR; result.Resource = null; } else { if (!string.IsNullOrEmpty(orderInfo.ExperienceVoucherCode)) { //var isUseCoupon = _couponService.Exist(orderInfo.ExperienceVoucherCode); //if (isUseCoupon != 3) //{ // orderInfo.ExperienceVoucherCode = ""; //} using (var scope = new TransactionScope())//创建事务 { _couponService.UpdatebycouponCode(orderInfo.ExperienceVoucherCode); orderInfo.ExperienceVoucherCode = null; _orderService.UpdateOrder(orderInfo); scope.Complete();//这是最后提交事务 } } var productInfo = _service.GetProductInfo(orderInfo.ProductCode); result.Status = Result.SUCCEED; result.Resource = new { orderInfo = orderInfo, productInfo = productInfo }; } result.Msg = msg; } else { result.Status = ResultType; result.Resource = ReAccessToken; result.Msg = TokenMessage; } } catch (Exception ex) { LogHelper.WriteLog("GetPayPage orderCode" + orderCode, ex); result.Status = Result.FAILURE; result.Msg = ex.Message; } LogHelper.WriteLog("GetPayPage result" + Json(result)); return(Json(result)); }
public void loadDataForEditOrder(int orderId) { if (!Global.isAdmin()) { disableForm(); } cbxCustomer.Enabled = false; // Don't allow change Customer isUpdating = true; OrderService orderService = new OrderService(); order = orderService.GetOrder(orderId); old_order = order; if (order != null) { if (orderDetails == null) { OrderDetailService orderDetailService = new OrderDetailService(); orderDetails = new BindingList<OrderDetail>(orderDetailService.SelectOrderDetailByWhere(o => o.OrderId == order.Id)); old_orderDetails = new List<OrderDetail>(); foreach (OrderDetail od in orderDetails) { old_orderDetails.Add(new OrderDetail { AttributeId = od.AttributeId, ProductId = od.ProductId, UnitId = od.UnitId, OrderId = od.OrderId, NumberUnit = od.NumberUnit }); } } } }
public OrdersController(OrderService orderService) { _orderService = orderService; }
public ActionResult EditPackageGold(string PackageID, string Price, string Duration, string OrderDetailID) { b2bMemberPaid mem = new b2bMemberPaid(); b2bOrder order = new b2bOrder(); b2bOrderDetail orderDe = new b2bOrderDetail(); var svOrder = new OrderService(); var svMember = new MemberService(); try { #region Set b2bMemberPaid var countMem = svMember.SelectData <b2bMemberPaid>("*", " CreatedDate = GetDate() AND RowFlag > 0"); int CountMem = countMem.Count + 1; mem.MemberPaidCode = AutoGenCode("MPC", CountMem); mem.CompID = LogonCompID; mem.PaymentStatus = "B"; mem.IsShow = true; mem.IsDelete = false; #endregion #region Insert b2bMemberPaid svMember.InsertMemberPaid(mem); #endregion #region Set b2bOrder order.CompID = LogonCompID; order.MemberPaidID = mem.MemberPaidID; order.OrderStatus = "B"; order.TotalPrice = decimal.Parse(Price); order.IsShow = true; order.IsDelete = false; order.RowFlag = 1; order.IsInactive = false; order.IsSend = false; #endregion var OrderDetails = new List <b2bOrderDetail>(); #region Set Model Order Detail var countOrder = svMember.SelectData <b2bOrderDetail>("*", " CreatedDate = GetDate() AND RowFlag > 0"); int CountOrder = countOrder.Count + 1; List <int> PackagesId = new List <int>(); foreach (string ID in PackageID.Split(',')) { if (!string.IsNullOrEmpty(ID)) { int intID; bool isNum = int.TryParse(ID, out intID); if (isNum) { PackagesId.Add(intID); } } } for (var i = 0; i < PackagesId.Count(); i++) { var GetPackage = svMember.SelectData <b2bPackage>("*", "PackageID = " + PackagesId[i]).First(); var GetOrderDetail = svMember.SelectData <b2bOrderDetail>("*", "IsDelete = 0 AND PackageID = " + PackagesId[i]).First(); var detail = new b2bOrderDetail(); detail.OrderType = 2; detail.PackageID = PackagesId[i]; detail.RowFlag = 1; detail.IsDelete = false; detail.IsInactive = false; detail.OrderDetailCode = AutoGenCode("ORT", CountOrder); detail.PackagePrice = decimal.Parse(Price); detail.OrderCount = (byte)(DataManager.ConvertToInteger(GetOrderDetail.OrderCount) + 1); detail.OptionValue = GetPackage.OptionValue; detail.OptionValueUnit = GetPackage.OptionValueUnit; detail.Duration = DataManager.ConvertToInteger(Duration); CountOrder++; OrderDetails.Add(detail); } #endregion #region Insert b2bOrder svOrder.InsertOrder(order, OrderDetails); #endregion if (svOrder.IsResult) { UpdateInactive(OrderDetailID); SendEmailOrderPackage(Price); } } catch (Exception ex) { return(Json(new { IsSuccess = false })); } return(Json(new { IsSuccess = true })); }
/// <summary> /// Run the code example. /// </summary> public void Run(AdManagerUser user) { using (OrderService orderService = user.GetService <OrderService>()) { // Set the ID of the order. long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE")); // Create statement to select the order. StatementBuilder statementBuilder = new StatementBuilder() .Where("id = :id") .OrderBy("id ASC") .Limit(1) .AddValue("id", orderId); // Set default for page. OrderPage page = new OrderPage(); List <string> orderIds = new List <string>(); int i = 0; try { do { // Get orders by statement. page = orderService.getOrdersByStatement(statementBuilder.ToStatement()); if (page.results != null) { foreach (Order order in page.results) { Console.WriteLine( "{0}) Order with ID = '{1}', name = '{2}', and status ='{3}' " + "will be approved.", i, order.id, order.name, order.status); orderIds.Add(order.id.ToString()); i++; } } statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT); } while (statementBuilder.GetOffset() < page.totalResultSetSize); Console.WriteLine("Number of orders to be approved: {0}", orderIds.Count); if (orderIds.Count > 0) { // Modify statement for action. statementBuilder.RemoveLimitAndOffset(); // Create action. ApproveAndOverbookOrders action = new ApproveAndOverbookOrders(); // Perform action. UpdateResult result = orderService.performOrderAction(action, statementBuilder.ToStatement()); // Display results. if (result != null && result.numChanges > 0) { Console.WriteLine("Number of orders approved: {0}", result.numChanges); } else { Console.WriteLine("No orders were approved."); } } } catch (Exception e) { Console.WriteLine("Failed to approve orders. Exception says \"{0}\"", e.Message); } } }