/// <summary> /// Opens the single page for an order with data to edit /// </summary> /// <param name="orderToEdit"></param> /// <returns></returns> public IActionResult SingleEdit(int orderToEdit) { var order = orderRepo.RetrieveOrderById(orderToEdit); var mapperOne = mapextension.OrdertoUserOrderViewModel(); UserOrderViewModel model = mapperOne.Map <UserOrderViewModel>(order); model.ShoppingCart = new ShoppingCartViewModel(); model.ShoppingCart.cartId = 1; model.ShoppingCart.ItemsInCart = new List <CartItemViewModel>(); model.ProductsInSystem = new List <ProductOverviewViewModel>(); foreach (var c in order.RetrieveItemsInOrder()) { CartItemViewModel cmodel = new CartItemViewModel(); cmodel.Quantity = c.Quantity; var mapper = mapextension.CartItemToProductViewModel(); ProductViewModel p = mapper.Map <ProductViewModel>(c); cmodel.Product = p; model.ShoppingCart.ItemsInCart.Add(cmodel); } foreach (Product p in productRepo.RetrieveAllProducts()) { ProductOverviewViewModel pmodel = new ProductOverviewViewModel(); pmodel.ProductId = p.RetrieveProductId(); pmodel.ProductName = p.ProductName; model.ProductsInSystem.Add(pmodel); } return(View("SingleOrder", model)); }