public IActionResult Details(OrderProdListViewModel oprod) { if (!ModelState.IsValid) { return(View(oprod)); } return(RedirectToAction("Index")); }
public IActionResult Details(int id) { List <OrderProduct> oprod; List <OrderProdListViewModel> lprod = new List <OrderProdListViewModel>(); try { oprod = _context.OrderProducts .Where(p => p.OrderProductId == id) .OrderBy(p => p.ProductId) .ToList(); foreach (OrderProduct p in oprod) { OrderProdListViewModel pList = p.CopyTo <OrderProdListViewModel>(); //Get product information Product product = GetProductById(p.ProductId); pList.Name = product.Name; pList.ProductType = product.ProductType; pList.Price = product.Price; pList.Active = product.Active; //Get audit information from order Order order = GetOrderById(p.OrderId); pList.AddUserId = order.AddUserId; pList.AddDateTime = order.AddDateTime; pList.ChangeUserId = order.ChangeUserId; pList.ChangeDateTime = order.ChangeDateTime; lprod.Add(pList); } return(View(lprod)); } catch (Exception ex) { return(View("Error", new ErrorViewModel { Exception = ex })); } }