public async Task <int> UpdateItem(int orderId, OrderItemDto item) { OrderProducts entity = mapper.Map <OrderProducts>(item); entity.OrderId = orderId; return(await repository.UpdateItem(entity)); }
public async Task <ActionResult <OrderProducts> > PostOrderProducts([FromForm] OrderProducts orderProducts) { _context.OrderProducts.Add(orderProducts); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOrderProducts", new { id = orderProducts.Id }, orderProducts)); }
public async Task <bool> Handle(CancelOrderAndRefillInventoryCommand command, CancellationToken cancellationToken) { if (!ValidateCommand(command)) { return(false); } var order = await _orderRepository.GetById(command.OrderId); if (order == null) { await _mediatorHandler.PublishNotification(new DomainNotification("Order", "Order has not been found!")); return(false); } var items = new List <Item>(); order.OrderItems.ForEach(i => items.Add(new Item { Id = i.ProductId, Quantity = i.Quantity })); var orderProducts = new OrderProducts { OrderId = order.Id, Items = items }; order.AddEvent(new OrderCancelledEvent(order.Id, order.CustomerId, orderProducts)); order.ToDraft(); return(await _orderRepository.UnitOfWork.Commit()); }
public OrderCancelledEvent(Guid orderId, Guid customerId, OrderProducts orderProducts) { AggregateId = orderId; OrderId = orderId; CustomerId = customerId; OrderProducts = orderProducts; }
public async Task <bool> Handle(OpenOrderCommand command, CancellationToken cancellationToken) { if (!ValidateCommand(command)) { return(false); } var order = await _orderRepository.GetOrderDraftByCustomerId(command.CustomerId); order.OpenOrder(); var items = new List <Item>(); order.OrderItems.ForEach(i => items.Add(new Item { Id = i.ProductId, Quantity = i.Quantity })); var orderProducts = new OrderProducts { OrderId = order.Id, Items = items }; order.AddEvent(new OrderCreatedEvent(order.Id, order.CustomerId, order.TotalAmount, orderProducts, command.CardName, command.CardNumber, command.CardExpiryDate, command.CardCvvCode)); _orderRepository.Update(order); return(await _orderRepository.UnitOfWork.Commit()); }
public override OrderProduct AddToCart(OrderType opType, int productId, int quantity, NameValueCollection paras) { SuitId = productId; int typecode; if (int.TryParse(paras["typecode"], out typecode)) { typecode = 0; } NoName.NetShop.Solution.BLL.SuiteBll sbll = new SuiteBll(); SolutionProductBll spbll = new SolutionProductBll(); SuiteModel smodel = sbll.GetModel(SuitId); List <SolutionProductModel> list = spbll.GetModelList(SuitId); this.OrderProducts.Clear(); foreach (SolutionProductModel model in list) { OrderProduct op = OrderProductFactory.Instance().CreateOrderProduct(model.ProductId, model.Quantity, opType, paras); op.Key = this.Key + "_op" + this.GetSerial(); op.Container = this; if (op != null) { OrderProducts.Add(op); } } this.DerateFee = this.ProductSum - smodel.Price; _score = smodel.Score; return(null); }
public static List <OrderProducts> GetOrderProducts() { List <OrderProducts> list = new List <OrderProducts>(); string connectionString = ConfigurationManager.ConnectionStrings["Week08Day03"].ConnectionString; string query = @"SELECT [OrderID], [ProductID], [Quantity] FROM [OrderProducts]"; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); var command = new SqlCommand(query, connection); using (var reader = command.ExecuteReader()) { while (reader.Read()) { OrderProducts temp = new OrderProducts(); temp.OrderID = GetIntOrZero(reader["OrderID"]); temp.ProductID = GetIntOrZero(reader["ProductID"]); temp.Quantity = GetIntOrZero(reader["Quantity"]); list.Add(temp); } } } return(list); }
public override OrderProduct AddToCart(OrderType opType, int productId, int quantity, NameValueCollection paras) { int typecode; if (int.TryParse(paras["typecode"], out typecode)) { typecode = 0; } OrderProduct op = OrderProducts.Find(c => c.ProductID == productId && c.TypeCode == typecode); if (op == null) { op = OrderProductFactory.Instance().CreateOrderProduct(productId, quantity, opType, paras); op.Key = this.Key + "_op" + this.GetSerial(); op.Container = this; this.ContinueShopUrl = op.ProductUrl; if (op != null) { OrderProducts.Add(op); } } else { op.SetQuantiy(op.Quantity + quantity); } return(op); }
private async Task ExecuteMethodReturnsNoSelectedProducts() { //Arrange var mocks = GetMocks(); var users = GetUsers().AsQueryable().BuildMock(); SetSettingsInDb(mocks.userMock, users); mocks.dbMock.Setup(m => m.Users).Returns(mocks.userMock.Object); var orderCommand = new OrderProducts(mocks.dbMock.Object); var message = new Message() { Chat = new Chat() { Id = 1 } }; var client = new TelegramBotClient(AppConfig.Token); //Act var result = await orderCommand.Execute(message, client); //Assert Assert.NotNull(result); Assert.False(result?.isSuccessed); Assert.Equal("Cart is null", result?.Message); }
public Order ToModel(int id) { return(new Order() { ID = id, Email = Email, Updates = Updates, FirstName = FirstName, LastName = LastName, ShippingMethod = ShippingMethod, ShippingPrice = ShippingPrice, PaymentMethod = PaymentMethod, BillingStreet = BillingStreet, BillingApartment = BillingApartment, BillingCity = BillingCity, BillingCountry = BillingCountry, BillingZip = BillingZip, ShippingStreet = ShippingStreet, ShippingApartment = ShippingApartment, ShippingCity = ShippingCity, ShippingCountry = ShippingCountry, ShippingZip = ShippingZip, VAT = VAT, OrderProducts = OrderProducts.Select(opf => opf.ToModel()).ToList() }); }
internal static void PlaceOrder(List <Product> ShoppingCart, Billing BillingInfo, Customer CurrentCustomer, Location CurrentLocation, List <int> Quantities) { DateTime now = System.DateTime.Now; using (var DB = new P0Context()) { Order Order = new Order { CustomerID = CurrentCustomer.CustomerID, LocationID = CurrentLocation.LocationID, OrderTime = now.ToString() }; OrderDAO.AddOrders(Order, DB); LocationProductsDAO.LoadLocationProductsList(DB); foreach (Product p in ShoppingCart) { int QuantityIndex = ShoppingCart.IndexOf(p); OrderProducts OP = new OrderProducts { OrderID = Order.OrderID, ProductID = p.ProductID, Quantity = Quantities[QuantityIndex] }; OrderProductsDAO.AddOrderProducts(OP, DB); LocationProducts LP = DB.LocationProductsList.Single( x => (x.LocationID == CurrentLocation.LocationID && x.ProductID == p.ProductID)); LP.Inventory -= OP.Quantity; LocationProductsDAO.UpdateLocationProducts(LP, DB); } } }
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 async Task <IActionResult> PutOrderProducts(int id, [FromForm] OrderProducts orderProducts) { if (id != orderProducts.Id) { return(BadRequest()); } _context.Entry(orderProducts).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderProductsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task ShouldReturnScheduleInputOrderObjectWhenScheduleTypeIsDay() { _mockDayComparable.Setup(x => x.Compare(It.IsAny <DayOfWeek>())).Returns(true); var scheduleOrder = new ScheduleOrder( _mockGasStationScheduleRepo.Object , _mockGasStationScheduleByDayRepo.Object , _mockGasStationTanksScheduleRepo.Object , _mockGasStationScheduleByTimeRepo.Object , _mockDayComparable.Object , _mockTimeIntervalComparable.Object , _mockOrderRepository.Object ); var gasStation = _orderData.GasStations.First(); var result = await scheduleOrder.CreateAsync((gasStation, _orderData.OrderStrategies.First().OrderType)); Assert.True(result.IsSuccess); var lineItemsTankIds = result.Entity !.OrderProducts.Select(x => x.TankId).ToList(); var gasStationScheduleTanks = _orderData.GasStationTankSchedules.Where(x => x.TankId == 1 || x.TankId == 2).ToList(); _mockDayComparable.Verify(x => x.Compare(It.IsAny <DayOfWeek>()), Times.Once); Assert.Equal(OrderType.Schedule, result.Entity !.OrderType); Assert.Equal(2, result.Entity !.OrderProducts.Count()); Assert.True(lineItemsTankIds.Exists(x => x == gasStationScheduleTanks .FirstOrDefault().TankId)); Assert.True(lineItemsTankIds.Exists(x => x == gasStationScheduleTanks .LastOrDefault().TankId)); Assert.Equal(result.Entity !.OrderProducts.FirstOrDefault( x => x.TankId == gasStationScheduleTanks.FirstOrDefault().TankId) .Quantity, gasStationScheduleTanks.FirstOrDefault().Quantity); Assert.Equal(result.Entity !.OrderProducts.FirstOrDefault( x => x.TankId == gasStationScheduleTanks.LastOrDefault().TankId) .Quantity, gasStationScheduleTanks.LastOrDefault().Quantity); }
internal static void PlaceOrder(List <ProductInStock> ShoppingCart, Billing BillingInfo, Shipping ShippingInfo, Customer CurrentCustomer, Location CurrentLocation, P1Context _context) { DateTime now = System.DateTime.Now; var DB = _context; Order Order = new Order { CustomerID = CurrentCustomer.CustomerID, LocationID = CurrentLocation.LocationID, BillingID = BillingInfo.BillingID, ShippingID = ShippingInfo.ShippingID, OrderTime = now.ToString() }; OrderDAO.AddOrders(Order, DB); LocationProductsDAO.LoadLocationProductsList(DB); foreach (ProductInStock p in ShoppingCart) { OrderProducts OP = new OrderProducts { OrderID = Order.OrderID, ProductID = p.ProductID, Quantity = p.Quantity }; OrderProductsDAO.AddOrderProducts(OP, DB); LocationProducts LP = DB.LocationProductsList.Single( x => (x.LocationID == CurrentLocation.LocationID && x.ProductID == p.ProductID)); LP.Inventory -= OP.Quantity; LocationProductsDAO.UpdateLocationProducts(LP, DB); } }
public async Task <Order> AddToOrderAsync(string accountId, IEnumerable <Product> products) { Order tempOrder = await CreateOrderAsync(accountId); foreach (var tempProduct in products) { tempOrder = await FindLastOrderAsync(accountId); if (tempOrder.OrderProducts.Any(p => p.ProductId == tempProduct.Id)) { continue; } var newOrderProducts = new OrderProducts { OrderId = tempOrder.Id, ProductId = tempProduct.Id }; storeContext.OrdersProducts.Add(newOrderProducts); } await storeContext.SaveChangesAsync(); return(tempOrder); }
public async Task <ActionResult <OrderProducts> > bookedOrderdetail(OrderProducts agentOrderStatusId) { var data = (from //agent_orderstatus in _context.AgentOrderStatus join order_product in _context.OrderProducts //on agent_orderstatus.Id equals order_product.AgentOrderStatusId join inventory in _context.Inventory on order_product.InventoryId equals inventory.Id where order_product.AgentOrderStatusId == agentOrderStatusId.AgentOrderStatusId join products in _context.Products on inventory.ProductId equals products.Id //join targettype in _context.TargetStatusType on agent_orderstatus.AgentTargetStatusId equals targettype.Id //where targettype.Id==1 //join ordertype in _context.OrderStatusType on agent_orderstatus.OrderStatusId equals ordertype.Id //where ordertype.Id == 2 select new { name = products.Name, category = products.Category, company = products.Company, inv_price = inventory.Price, qty = order_product.QTY }).ToList(); return(Ok(new { GetBookedOrderStatus = "GetSuccess", customerorderList = data })); // return orderProducts; }
public void CheckOut(User user) { Order order = new Order { UserId = user.Id, TotalPrice = _cart.Sum(pair => pair.Key.ProductPrice * pair.Value), CreatedAt = DateTime.Now }; _context.Orders.Add(order); _context.SaveChanges(); _context.UserOrders.Add(new UserOrders { User = user, OrderId = order.OrderId }); foreach (KeyValuePair <Product, int> item in _cart) { var product = _context.Products.FirstOrDefault(product1 => product1.ProductId == item.Key.ProductId); product.ProductQuantity -= item.Value; _context.Products.Update(product); var orderProduct = new OrderProducts { OrderId = order.OrderId, ProductId = product.ProductId , Quantity = item.Value, UnitPrice = item.Key.ProductPrice, TotalPrice = item.Key.ProductPrice * item.Value }; _context.OrderProducts.AddRange(orderProduct); } _context.SaveChanges(); }
public ActionResult DeleteConfirmed(int id) { OrderProducts orderProducts = db.OrderProducts.Find(id); db.OrderProducts.Remove(orderProducts); db.SaveChanges(); return(RedirectToAction("Index")); }
// Добавление изделия в заказ private void ButtonAddProduct_Click(object sender, RoutedEventArgs e) { Window windowAdd = new OrderProductsRecordWindow(orderId); windowAdd.ShowDialog(); RefreshList(); Result = OrderProducts.CalcualteMaterials(orderId, connection); }
public Order AddProduct(OrderProduct product) { OrderProducts.Add(product); TotalPrice += product.Price * product.Quantity; TotalPriceWithVat += product.PriceWithVat * product.Quantity; TotalVat += product.Vat * product.Quantity; return(this); }
public IActionResult Checkout(Customers customers) { var c = context.Customers.Where(x => x.CustomerEmail == customers.CustomerEmail).SingleOrDefault(); //context.Customers.Add(customers); c.CustomerFirstName = customers.CustomerFirstName; c.CustomerLastName = customers.CustomerLastName; c.CustomerUserName = customers.CustomerUserName; c.CustomerEmail = customers.CustomerEmail; c.CustomerPhoneNumber = customers.CustomerPhoneNumber; c.CustomerCountry = customers.CustomerCountry; c.CustomerState = customers.CustomerState; c.CustomerGender = customers.CustomerGender; c.CustomerZipNumber = customers.CustomerZipNumber; c.CustomerAddress1 = customers.CustomerAddress1; c.CustomerAddress2 = customers.CustomerAddress2; c.CustomerPhoneNumber2 = customers.CustomerPhoneNumber2; c.CustomerCountry2 = customers.CustomerCountry2; c.CustomerState2 = customers.CustomerState2; c.CustomerZipNumber2 = customers.CustomerZipNumber2; c.SameAddress = customers.SameAddress; context.SaveChanges(); SessionHelper.SetObjectAsJson(HttpContext.Session, "cus", c); var amount = TempData["total"]; Orders orders = new Orders() { OrderAmount = Convert.ToSingle(amount), OrderDate = DateTime.Now, CustomerId = c.CustomerId }; context.Orders.Add(orders); context.SaveChanges(); var cart = SessionHelper.GetObectFromJson <List <Item> >(HttpContext.Session, "cart"); List <OrderProducts> orderProducts = new List <OrderProducts>(); for (int i = 0; i < cart.Count; i++) { OrderProducts orderProduct = new OrderProducts() { OrderId = orders.OrderId, Productid = cart[i].Products.ProductId, Quantity = cart[i].Quantity }; orderProducts.Add(orderProduct); } orderProducts.ForEach(n => context.OrderProducts.Add(n)); context.SaveChanges(); TempData["cust"] = c.CustomerId; //TempData["flag"] = 0; return(RedirectToAction("Status", "cart")); }
public Orderproduct ParseOrderProduct(OrderProducts orderproduct) { return(new Entity.Orderproduct { Id = orderproduct.OrdProdId, Idproducts = orderproduct.RecID, Idorder = orderproduct.OrdID, Productnumb = orderproduct.RecQuan }); }
public ActionResult OrderDetails(long orderId) { OrderProducts o = new OrderProducts { order = _dbContext.Orders.Where(e => e.orderId == orderId).FirstOrDefault(), orderItems = _dbContext.Order_Product.Where(e => e.orderId == orderId).ToList() }; return(View(o)); }
public ActionResult Edit(OrderProducts orderProducts) { if (ModelState.IsValid) { db.Entry(orderProducts).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(orderProducts)); }
public ActionResult Create(OrderProducts orderProducts) { if (ModelState.IsValid) { db.OrderProducts.Add(orderProducts); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(orderProducts)); }
private void HandleOrderProducts(OrderProducts cmd) { var products = this.QueryProducts(cmd.ProductIDs); this.Sender.Tell( new OrderCreated { Order = new Order { Id = 1, Products = products, TotalPrice = products.Sum(p => p.Price) } }); }
public OrderInventoryConfirmedEvent(Guid orderId, Guid customerId, decimal total, OrderProducts orderProducts, string cardName, string cardNumber, string expiryDate, string cvvCode) { OrderId = orderId; CustomerId = customerId; Total = total; OrderProducts = orderProducts; CardName = cardName; CardNumber = cardNumber; ExpiryDate = expiryDate; CvvCode = cvvCode; }
public OrderCreatedEvent(Guid orderId, Guid customerId, decimal total, OrderProducts orderProducts, string cardName, string cardNumber, string cardExpiryDate, string cardCvvCode) { OrderId = orderId; CustomerId = customerId; Total = total; OrderProducts = orderProducts; CardName = cardName; CardNumber = cardNumber; CardExpiryDate = cardExpiryDate; CardCvvCode = cardCvvCode; }
public async Task <bool> DebitOrderProducts(OrderProducts orderProducts) { foreach (var item in orderProducts.Items) { if (!await DebitInventoryItem(item.Id, item.Quantity)) { return(false); } } return(await _productRepository.UnitOfWork.Commit()); }