public ActionResult Create() { var orders = receiptService.ChangeOrderStatus(); var receipt = receiptService.CreateReceipt(User.Username, orders); var receiptOrder = receiptService.CreateReceiptOrder(receipt, orders); var userReceipt = receiptService.CreateUserReceipt(receipt); //TODO: Fix it!!! //var products = productService.GetAllProducts(); ; //receiptService.context.Entry(receiptOrder).Reload(); //Thread.Sleep(3000); var orderViewModels = receiptOrder.Orders .Select(o => new OrderViewModel { Id = o.Id, Product = o.Product.Name, Quantity = o.Quantity, Price = o.Product.Price }) .ToList(); var receiptViewModel = new ReceiptDetailsViewModel { Id = receipt.Id, Orders = orderViewModels, IssuedOn = receipt.IssuedOn.ToString("dd/MM/yyyy"), Cashier = receipt.Cashier.Username }; var total = orderViewModels.Sum(ovm => ovm.Quantity * ovm.Price); receiptViewModel.Total = total; return(View(receiptViewModel, "Details")); }