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 ; }
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 ActionResult MyPage() { if (!LoginStatus()) { return RedirectToAction("Index", "Home"); } string Email = (string)Session["Email"]; var Customer = _accountBLL.GetCustomer(Email); var customerView = new CustomerView() { Id= Customer.CustomerId, Email = Customer.Email, Firstname = Customer.Firstname, Lastname = Customer.Lastname, Address = Customer.Address, Zipcode = Customer.Zipcode, City = Customer.City }; var orders = Customer.Orders; var customerOrders = new List<OrderView>(); foreach (var o in orders) { 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, Id = l.ProductId, Name = l.ProductName }; order.Orderlines.Add(orderline); } customerOrders.Add(order); } //var customerOrders = Customer.Orders.Select(o => new OrderView() //{ // OrderId = o.OrderId, // Orderlines = o.Orderlines.Select(l => new OrderlineView() // { // OrderlineId = l.OrderlineId, // Count = l.Count, // Product = new ProductView() // { // ProductId = l.ProductId, // ProductName = l.ProductName, // Price = l.ProductPrice // } // }).ToList() //}).ToList(); ViewBag.LoggedIn = LoginStatus(); ViewBag.Customer = customerView; ViewBag.CustomerOrders = customerOrders; return View(); }