public async Task <ActionResult <CartProductView> > updateOrderProducts([FromBody] PlaceOrderView orderProductsList) { foreach (CartProductView orderProducts in orderProductsList.ListOrderProduct) { Inventory previousInven = _context.Inventory.Find(orderProducts.InventoryId); previousInven.Id = orderProducts.InventoryId; previousInven.TotalPacket_Cartoon += orderProducts.QTY; _context.Inventory.Update(previousInven); OrderProducts beingUpdate_orderProducts = _context.OrderProducts.Find(orderProducts.Id); beingUpdate_orderProducts.Id = orderProducts.Id; beingUpdate_orderProducts.QTY -= orderProducts.QTY; beingUpdate_orderProducts.OrderDate = System.DateTime.Parse(orderProducts.OrderDate); await _context.SaveChangesAsync(); } AgentOrderStatus agentOrderStatus = _context.AgentOrderStatus.Find(orderProductsList.ListOrderProduct[0].AgentOrderStatusId); agentOrderStatus.AgentTargetStatusId = 3; agentOrderStatus.OrderStatusId = 2; //productive target status(mean booking->(orderstatus:1) success) _context.AgentOrderStatus.Update(agentOrderStatus); await _context.SaveChangesAsync(); return(Ok(new { returnCustomerOrder = "ReturnSuccess" })); // return CreatedAtAction("GetOrderProducts", new { id = orderProducts.Id }, orderProducts); }
public ActionResult PlaceOrder(PlaceOrderView POV) { if (ModelState.IsValid) { DataManager DM = new DataManager(); DM.PlaceOrder(POV); return(RedirectToAction("MyOrders", "CUser")); } return(View()); }
public PlaceOrderViewModel(PlaceOrderView parent, string action, OrderModel orderModel) { db = Database.getInstance(); this.parent = parent; this.action = action; if (orderModel != null) { this.orderModel = orderModel; } switch (action) { case "ADD": { ActionLable = "Place Order"; ActionButton = "Place"; Sites = new ObservableCollection <SiteModel>(db.db_GetAllSites().Where(i => i.SiteStatus.Equals(Status.ACTV))); Clients = new ObservableCollection <ClientModel>(db.db_GetAllClients().Where(i => i.ClientStatus.Equals(Status.ACTV))); break; } case "MDFY": { ActionLable = "Modify Order"; ActionButton = "Modify"; Sites = new ObservableCollection <SiteModel>(db.db_GetAllSites()); Clients = new ObservableCollection <ClientModel>(db.db_GetAllClients()); break; } case "CNCL": { ActionLable = "Cancel Order"; ActionButton = "Cancel"; Sites = new ObservableCollection <SiteModel>(db.db_GetAllSites()); Clients = new ObservableCollection <ClientModel>(db.db_GetAllClients()); break; } default: { break; } } resetFields(); StatusString = ""; StatusStringFlag = Visibility.Collapsed; }
public void PlaceOrder(PlaceOrderView POV) { Address paddr = new Address(); Address saddr = new Address(); using (CMSProjectEntities db = new CMSProjectEntities()) { paddr.StreetAddress = POV.PickupAddressSA; paddr.City = POV.PickupAddressCity; paddr.State = POV.PickupAddressState; paddr.Pincode = POV.PickupAddressPincode; saddr.StreetAddress = POV.ShippingAddressSA; saddr.City = POV.ShippingAddressCity; saddr.State = POV.ShippingAddressState; saddr.Pincode = POV.ShippingAddressPincode; db.Addresses.Add(paddr); db.SaveChanges(); db.Addresses.Add(saddr); db.SaveChanges(); User user = db.Users.Where(o => o.Username.Equals(HttpContext.Current.User.Identity.Name)).FirstOrDefault(); CustomerUser CU = db.CustomerUsers.Where(o => o.UserID.Equals(user.UserID)).FirstOrDefault(); CustomerOrder CO = new CustomerOrder(); CO.CustomerID = CU.CustomerID; CO.OrderDate = DateTime.Now; CO.ShippedDate = null; CO.PickupAddressID = db.Addresses.Where(o => o.StreetAddress.Equals(paddr.StreetAddress)).FirstOrDefault().AddressID; CO.ShippingAddressID = db.Addresses.Where(o => o.StreetAddress.Equals(saddr.StreetAddress)).FirstOrDefault().AddressID; CO.Weight = POV.Weight; CO.OrderValue = POV.OrderValue; db.CustomerOrders.Add(CO); db.SaveChanges(); TrackingTBL tracking = new TrackingTBL(); tracking.OrderStatusID = 0; tracking.OrderID = CO.OrderID; db.TrackingTBLs.Add(tracking); db.SaveChanges(); PaymentTBL pay = new PaymentTBL(); pay.Value = CO.OrderValue; pay.PaymentDate = null; pay.PaymentStatusID = 1; pay.OrderID = CO.OrderID; db.PaymentTBLs.Add(pay); db.SaveChanges(); } }
public async Task <ActionResult <CartProductView> > PostOrderProducts([FromBody] PlaceOrderView orderProductsList) { string status = ""; try { foreach (CartProductView orderProducts in orderProductsList.ListOrderProduct) { Inventory previousInven = _context.Inventory.Find(orderProducts.InventoryId); previousInven.Id = orderProducts.InventoryId; previousInven.TotalPacket_Cartoon -= orderProducts.QTY; _context.Inventory.Update(previousInven); OrderProducts newOrderProduct = new OrderProducts(); newOrderProduct.AgentOrderStatusId = orderProducts.AgentOrderStatusId; newOrderProduct.InventoryId = orderProducts.InventoryId; newOrderProduct.OrderDate = System.DateTime.Parse(orderProducts.OrderDate); newOrderProduct.QTY = orderProducts.QTY; _context.OrderProducts.Add(newOrderProduct); await _context.SaveChangesAsync(); } AgentOrderStatus agentOrderStatus = _context.AgentOrderStatus.Find(orderProductsList.ListOrderProduct[0].AgentOrderStatusId); agentOrderStatus.AgentTargetStatusId = 3; //productive target status(mean booking->(orderstatus:1) success) _context.AgentOrderStatus.Update(agentOrderStatus); await _context.SaveChangesAsync(); status = "BookingSuccess"; } catch (Exception ex) { status = ex.Message; } // status = ; return(Ok(new { postCustomerOrder = status })); // return CreatedAtAction("GetOrderProducts", new { id = orderProducts.Id }, orderProducts); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); var builder = new ContainerBuilder(); builder.RegisterModule(new NHibernateSessionModule()); //builder.RegisterModule(new ReportingSessionModule()); builder.RegisterModule(new QueryModule()); builder.RegisterControllers(Assembly.GetExecutingAssembly()); var container = builder.Build(); _container = container; QueryModule._container = _container; DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); var rabbitMQPublisher = new RabbitMQPublisher(System.Configuration.ConfigurationManager.AppSettings["CLOUDAMQP_URL"]); //Use RabbitMQ //var commandBus = new CommandBus(rabbitMQPublisher); var commandBus = new CommandBus(); var sessionFactory = container.Resolve<ISessionFactory>(); IEventStore eventStore = new NHibernateEventStore(commandBus, sessionFactory); //Context var transferMoneyContext = new TransferMoneyContext(eventStore); var createBankAccountContext = new CreateBankAccountContext(eventStore); var changeAccountAndBalanceContext = new ChangeAccountNameAndBalanceContext(eventStore); var createCustomerContext = new CreateCustomerContext(eventStore); var addCustomerAddressContext = new AddCustomerAddressContext(eventStore); var stockNewProductContext = new StockNewProductContext(eventStore); var placeOrderContext = new PlaceOrderContext(eventStore); //Register Command commandBus.RegisterHandlerCommand<OpenAccountCommand>(createBankAccountContext.Handle); commandBus.RegisterHandlerCommand<TransferMoneyCommand>(transferMoneyContext.Handle); commandBus.RegisterHandlerCommand<ChangeAccountNameAndBalanceCommand>(changeAccountAndBalanceContext.Handle); commandBus.RegisterHandlerCommand<CreateCustomerCommand>(createCustomerContext.Handle); commandBus.RegisterHandlerCommand<AddCustomerAddressCommand>(addCustomerAddressContext.Handle); commandBus.RegisterHandlerCommand<CreateProductCommand>(stockNewProductContext.Handle); commandBus.RegisterHandlerCommand<PlaceOrderCommand>(placeOrderContext.Handle); //Report View var accountReportView = new AccountReportView(sessionFactory); //Register Event commandBus.RegisterHandlerEvent<AccountCreatedEvent>(accountReportView.Handle); commandBus.RegisterHandlerEvent<AccountNameAndBalanceChangedEvent>(accountReportView.Handle); commandBus.RegisterHandlerEvent<BalanceDecreasedEvent>(accountReportView.Handle); commandBus.RegisterHandlerEvent<BalanceIncreasedEvent>(accountReportView.Handle); //Report View var customerReportView = new CustomerReportView(container.Resolve<ISessionFactory>()); //Register Event commandBus.RegisterHandlerEvent<CustomerCreatedEvent>(customerReportView.Handle); commandBus.RegisterHandlerEvent<CustomerAddressAddedEvent>(customerReportView.Handle); var placeOrderView = new PlaceOrderView(container.Resolve<ISessionFactory>()); commandBus.RegisterHandlerEvent<OrderPlacedEvent>(placeOrderView.Handle); var productStockReportView = new ProductStockReportView(container.Resolve<ISessionFactory>()); commandBus.RegisterHandlerEvent<ProductCreatedEvent>(productStockReportView.Handle); //ServiceLocator.Pub = rabbitMQPublisher; ServiceLocator.Bus = commandBus; //ServiceLocator.Sub = rabbitMQSubsriber; }