public PartialViewResult OrdersPartial(int CustomerId) { List<OrderModel> orderModels; if (CustomerId > 0) orderModels = _adminBLL.GetCustomer(CustomerId).Orders; else orderModels = _adminBLL.GetAllOrders(); var orderViews = new List<OrderView>(); foreach (var o in orderModels) { var order = new OrderView(); order.Date = o.Date; order.OrderId = o.OrderId; order.Orderlines = new List<OrderlineView>(); foreach (var l in o.Orderlines) { var orderline = new OrderlineView(); orderline.Count = l.Count; orderline.OrderlineId = l.OrderlineId; orderline.Product = new ProductView() { Price = l.ProductPrice, ProductId = l.ProductId, ProductName = l.ProductName }; order.Orderlines.Add(orderline); } orderViews.Add(order); } var productModels = _adminBLL.GetAllProducts(); var productViews = new List<ProductView>(); foreach (var productModel in productModels) { var productview = new ProductView() { ProductId = productModel.ProductId, ProductName = productModel.ProductName, Description = productModel.Description, Price = productModel.Price, Stock = productModel.Stock, ImageUrl = productModel.ImageUrl, CategoryName = productModel.CategoryName }; productViews.Add(productview); } string Title = CustomerId == 0 ? "Ordreadministrasjon - Alle ordre" : "Ordreadministrasjon - Kunde"; ViewBag.Orders = orderViews; ViewBag.Products= productViews; ViewBag.Title = Title; return PartialView(); }
public OrderView GetReciept(int OrderId) { Order reciept = _orderBLL.GetReciept(OrderId); var orderlines = new List<OrderlineView>(); foreach(var item in reciept.Orderlines) { var product = new ProductView() { Id = item.ProductId, Name = item.ProductName, Price = item.ProductPrice, }; orderlines.Add(new OrderlineView() { OrderlineId = item.OrderlineId, Count = item.Count, Product = product }); } OrderView orderView = new OrderView() { OrderId = reciept.OrderId, Date = reciept.Date, Orderlines = orderlines, }; return orderView ; }