public IActionResult Order(OrderItemVM product) { var customer = _workContext.CurrentCustomer; var preOrder = _preorderService.GetActive(customer, "test"); if (preOrder == null) { preOrder = _preorderService.Create(new Domain.Preorder { CreatedAt = DateTime.Now, CustomerId = customer.Id, Status = "Active", Month = "test" }); } _preorderItemService.Add(new Domain.PreorderItem { DateAdded = DateTime.Now, PreorderId = preOrder.Id, ProductId = product.ProductId, ProductName = product.Name, ProductPrice = product.Price, Qty = 1 }, customer, "test"); return(View("/")); }
public async Task <OrderItemVM> GetOrderItemByIdAsync(int id) { var dbItem = await _db.OrderItems.GetByIdAsync(id); var order = _db.Orders.GetAll().FirstOrDefault(m => m.Id == dbItem.OrderId); var ret = new OrderItemVM(dbItem, order.Location.Currency); return(ret); }
// GET: UserAccount public ActionResult Index() { var currentUserId = "Empty"; if (User.Identity.IsAuthenticated) { currentUserId = User.Identity.GetUserId(); var orderList = _orderManager.GetOrdersByUserId(currentUserId); var orderDetailsVMList = new List <OrderDetailsVM>(); foreach (var i in orderList) { var orderDetailsVM = new OrderDetailsVM(); var orderVM = new OrderVM(); orderVM.Id = i.Id; orderVM.Address = i.Address; orderVM.Comment = i.Comment; orderVM.ContactId = i.ContactId; orderVM.Date = i.Date; orderVM.deliveryTypeID = i.DeliveryTypeID; orderVM.Email = i.Email; orderVM.Lname = i.Lname; orderVM.Name = i.Name; orderVM.Number = i.Number; orderVM.Phone = i.Phone; orderVM.Status = i.Status; orderVM.StatusId = i.StatusID; orderDetailsVM.Order = orderVM; orderVM = null; var orderItems = _orderManager.GetOrderItemsByOrderId(i.Id); var orderItemVMList = new List <OrderItemVM>(); foreach (var orderItem in orderItems) { var orderItemVM = new OrderItemVM(); orderItemVM.PurposeId = orderItem.PurposeId; orderItemVM.IsPromo = orderItem.IsPromo; orderItemVM.ItemId = orderItem.ItemId; orderItemVM.ItemName = orderItem.ItemName; orderItemVM.BrandName = orderItem.BrandName; orderItemVM.Count = orderItem.Count; orderItemVM.Price = orderItem.Price; orderItemVM.Currency = orderItem.Currency; orderItemVMList.Add(orderItemVM); orderItemVM = null; } orderDetailsVM.OrderItems = orderItemVMList; orderDetailsVMList.Add(orderDetailsVM); } return(View(orderDetailsVMList)); } return(RedirectToAction("Index", "Home")); }
public async Task <OrderItemVM> UpdateNewOrderItem(CreateOrderItemVM vm) { var dbItem = await _db.OrderItems.GetByIdAsync(vm.Id); dbItem.Count = vm.Count; dbItem.Status = vm.Status; var newItem = await _db.OrderItems.UpdateAsync(dbItem); var order = _db.Orders.GetAll().FirstOrDefault(m => m.Id == dbItem.OrderId); if (order != null) { var ret = new OrderItemVM(newItem, order.Location.Currency); return(ret); } throw new Exception("order not found"); }
public ActionResult Index(ICart cart) { var orderItems = cart.GetOrderItems(); var orderItemVMList = new List <OrderItemVM>(); foreach (var orderItemDTO in orderItems) { OrderItemVM buff = new OrderItemVM(); buff.PurposeId = orderItemDTO.PurposeId; buff.ItemId = orderItemDTO.ItemId; buff.BrandName = orderItemDTO.BrandName; buff.ItemName = orderItemDTO.ItemName; buff.IsPromo = orderItemDTO.IsPromo; buff.Count = orderItemDTO.Count; buff.Price = orderItemDTO.Price; buff.Currency = orderItemDTO.Currency; orderItemVMList.Add(buff); } return(View(orderItemVMList)); }
public ActionResult GetOrderItems(Guid orderId) { var orderItems = _orderManager.GetOrderItemsByOrderId(orderId); var orderItemVMList = new List <OrderItemVM>(); foreach (var orderItem in orderItems) { var buff = new OrderItemVM(); buff.PurposeId = orderItem.PurposeId; buff.IsPromo = orderItem.IsPromo; buff.ItemId = orderItem.ItemId; buff.ItemName = orderItem.ItemName; buff.BrandName = orderItem.BrandName; buff.Count = orderItem.Count; buff.Price = orderItem.Price; buff.Currency = orderItem.Currency; orderItemVMList.Add(buff); } return(PartialView(orderItemVMList)); }
public async Task <IEnumerable <OrderItemVM> > GetOrders(string id) { var orders = dataContext.Orders.Where(x => x.UserId == id).OrderByDescending(x => x.DateAccept).ToList(); var addresses = dataContext.OrderAddresses.Where(x => x.UserId == id).ToList(); var shoppingcards = dataContext.ShoppingCards.Where(x => x.UserId == id).ToList(); List <OrderItemVM> orderVMs = new List <OrderItemVM>(); foreach (var order in orders) { OrderItemVM orderItemVM = new OrderItemVM(); orderItemVM.Order = order; orderItemVM.OrderAddress = addresses.Where(x => x.OrderId == order.Id).FirstOrDefault(); orderItemVM.ShoppingCardVMs = shoppingcards.Where(x => x.OrderId == order.Id).ToList(); orderItemVM.Price = shoppingcards.Where(x => x.OrderId == order.Id).Sum(x => (x.Price * x.Quantity)); orderVMs.Add(orderItemVM); } return(orderVMs); }