public static CustomerOrderVM SetSubData(CustomerOrder model) { var data = CustomerOrderVM.MToVM(model); data.DateTime = DateTimeStorageVM.MToVM(DateTimeStorageService.GetByOID(model.ID, model.API).FirstOrDefault()); data.OrderItem = CustomerOrderItemService.SetSubDatas(CustomerOrderItemService.GetByCOID(model.ID, model.API)); return(data); }
public async Task <CustomerOrderVM> GetCustomerOrderByOrderId(Guid orderId) { if (orderId == Guid.Empty) { CustomerOrderVM customerOrderVM = new CustomerOrderVM(); return(customerOrderVM); } return(await orderRepository.GetCustomerOrderByOrderId(orderId)); }
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 static bool Insert(Guid id, Guid uid, Guid oid, Guid aid, Guid dtid, bool iS, float tc) { try { using (var context = new CentralProcessContext()) { var data = CustomerOrderVM.set(id, uid, oid, aid, dtid, iS, tc); context.CustomerOrderDB.Add(data); context.SaveChanges(); return(true); } } catch { return(false); } }
public async Task <IActionResult> DisplayOrders(int id) { var customer = await _context.Customers.FindAsync(id); var custOrders = new CustomerOrderVM(); custOrders.Customer = customer; var orders = await _context.Orders .Where(o => o.CustomerId == id) .ToListAsync <Order>(); custOrders.Orders = orders; return(View(custOrders)); }
public ActionResult MyOrder() { List <CustomerOrderVM> covm = new List <CustomerOrderVM>(); var orderHistoryList = db.OnlineInvoices.Where(o => o.UserName == HttpContext.User.Identity.Name).Include(os => os.OnlineSales).AsEnumerable().Select(o => new { id = o.OnlineInvoiceID, invNumber = o.InvoiceNumber, price = db.OnlineSales.Where(s => s.OnlineInvoiceID == o.OnlineInvoiceID).Sum(s => s.ItemPrice), status = o.IsPaid, date = o.OrderDate.ToString("MMM dd, yyyy") }); foreach (var item in orderHistoryList) { CustomerOrderVM obj = new CustomerOrderVM(); obj.OnlineInvoiceID = item.id; obj.InvoiceNumber = item.invNumber; obj.ItemPrice = item.price; obj.OrderDate = item.date; obj.IsPaid = item.status; covm.Add(obj); } return(View(covm)); }
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; }
public async Task <List <CustomerOrderVM> > GetAllCustomerOrders(Guid customerId) { List <CustomerOrderVM> customerOrder = await ctx.Order.Where(o => o.CustomerId == customerId) .Select(o => new CustomerOrderVM { OrderId = o.OrderId, CustomerId = o.CustomerId, CreatedDate = o.CreatedDate, TotalPrice = o.TotalPrice, ContactPhone = o.ContactPhone, DeliveryName = o.DeliveryName, DeliveryEmail = o.DeliveryEmail, DeliveryAddress = o.DeliveryAddress, DeliveryPrice = o.DeliveryPrice, DeliveryDate = o.DeliveryDate, NumberOfProducts = o.OrderProductSize.Count, StatusId = o.StatusId, StatusName = o.Status.Name }) .OrderByDescending(o => o.CreatedDate) .ToListAsync(); List <Guid> orderIds = customerOrder.Select(o => o.OrderId) .ToList(); foreach (Guid guid in orderIds) { OrderProductSize orderProductSize = await ctx.OrderProductSize.Where(o => o.OrderId == guid).FirstOrDefaultAsync(); CustomerOrderVM customerOrderVM = customerOrder.Where(o => o.OrderId == guid).FirstOrDefault(); customerOrderVM.FirstProductName = await ctx.ProductSize.Where(p => p.ColorId == orderProductSize.ColorId && p.ProductId == orderProductSize.ProductId && p.SizeId == orderProductSize.SizeId) .Select(p => p.ProductColor.Product.Name) .FirstOrDefaultAsync(); } return(customerOrder); }
public async Task <CustomerOrderVM> GetCustomerOrderByOrderId(Guid orderId) { CustomerOrderVM customerOrder = await ctx.Order.Where(o => o.OrderId == orderId) .Select(o => new CustomerOrderVM { OrderId = o.OrderId, CustomerId = o.CustomerId, CreatedDate = o.CreatedDate, TotalPrice = o.TotalPrice, ContactPhone = o.ContactPhone, DeliveryName = o.DeliveryName, DeliveryEmail = o.DeliveryEmail, DeliveryAddress = o.DeliveryAddress, DeliveryPrice = o.DeliveryPrice, DeliveryDate = o.DeliveryDate, NumberOfProducts = o.OrderProductSize.Count, StatusId = o.StatusId, StatusName = o.Status.Name }) .OrderByDescending(o => o.CreatedDate) .FirstOrDefaultAsync(); return(customerOrder); }
public OrderUpdatedEvent(CustomerOrderVM order) { Order = order; }