public void CreateOrderDB(int selectProd, int selectCust, int citySelect, int quant) { //string connectionString = SecretConfiguration.configurationString; string connectionString = ""; DbContextOptions <GameStoreContext> options = new DbContextOptionsBuilder <GameStoreContext>() .UseSqlServer(connectionString) .Options; using var context = new GameStoreContext(options); LocationData locDat = new LocationData(); Orders orders = new Orders(); OrderedProducts orderedProds = new OrderedProducts(); orders.CustomerId = selectCust; orders.Quantity = quant; orders.OrderDate = DateTime.Now; context.Orders.Add(orders); context.SaveChanges(); orderedProds.CustomerId = selectCust; orderedProds.OrderId = (int)orders.OrderId; orderedProds.ProductId = selectProd; orderedProds.LocationId = citySelect; context.OrderedProducts.Add(orderedProds); context.SaveChanges(); locDat.InventoryUpdate((int)orderedProds.LocationId, (int)orderedProds.ProductId, (int)orders.Quantity); //Add Decrementing Functionality To The Inventory Of The Location The Order is Created From.1 }
public IActionResult CompleteService(int id) { var service = _requestRepo.GetIdBy(id); service.Status = "Completed"; var last = 1; try { last = _transactionRepo.GetAll().LastOrDefault().TransactionKey; last++; } catch (Exception e) { } OrderedProducts orderedProd = new OrderedProducts(); orderedProd.Price = service.Price; orderedProd.ProductName = service.Description + " service"; orderedProd.Quantity = 1; orderedProd.TransactionID = last; _orderedRepository.Create(orderedProd); _requestRepo.Update(service); _notifRepo.AddNotification($"Your service has already been completed. Thank you for choosing us.", service.UserName); return(View("ServiceCompleted")); }
public static OrderModel MapViewModelToOrder(this OrderViewModel order, IOrderService _orderService) { OrderModel orderModel = new OrderModel() { OrderId = order.OrderId, OrderNumber = order.OrderNumber, DateofOrder = order.DateofOrder, DateDeleted = order.DateDeleted, EmployeeId = order.EmployeeId, OrderedProducts = new List <OrderedProducts>() }; foreach (var op in order.Products) { OrderedProducts orderedProduct = new OrderedProducts() { OrderId = order.OrderId, ProductId = op }; orderModel.OrderedProducts.Add(orderedProduct); } return(orderModel); }
public int CreateOrder(CustomerOrder customerOrder) { decimal orderTotal = 0; var cartItems = GetCartItems(); foreach (var item in cartItems) { var orderedProduct = new OrderedProducts { ProductId = Convert.ToInt32(item.ProductId), CustomerOrderId = customerOrder.Id, Quantity = item.Count }; orderTotal += Convert.ToDecimal((item.Count * item.Product.Price)); //orderTotal += (item.Count * item.Product.Price); // db.OrderedProducts.Add(orderedProduct); } customerOrder.Amount = orderTotal; db.SaveChanges(); EmptyCart(); return(customerOrder.Id); }
public void CreateOrderDB(int selectProd, int selectCust, int citySelect, int quant, string dateString) { string connectionString = SecretConfiguration.configurationString; DbContextOptions <GameStoreContext> options = new DbContextOptionsBuilder <GameStoreContext>() .UseSqlServer(connectionString) .Options; using var context = new GameStoreContext(options); Orders orders = new Orders(); OrderedProducts orderedProds = new OrderedProducts(); /*Random random = new Random(); * orders.OrderId = random.Next(10000, 99999);*/ orders.CustomerId = selectCust; orders.Quantity = quant; orders.OrderDate = DateTime.ParseExact(dateString, "MM/dd/yyyy", null); context.Orders.Add(orders); context.SaveChanges(); orderedProds.CustomerId = selectCust; orderedProds.OrderId = (int)orders.OrderId; orderedProds.ProductId = selectProd; orderedProds.LocationId = citySelect; context.OrderedProducts.Add(orderedProds); context.SaveChanges(); }
private async void Valider_Click(object sender, RoutedEventArgs e) { int completed = 0; if (ClientName.Text.Count() == 0) { ClientName.Background = new SolidColorBrush(Colors.Red); completed++; } if (Phone.Text.Count() == 0) { Phone.Background = new SolidColorBrush(Colors.Red); completed++; } if (ProductsList.Items.Count() == 0) { ClientName.Background = new SolidColorBrush(Colors.Red); completed++; } if (completed == 0) { if (LocalClient != null) { //Modify await DataHolder.ModifyClient( new Client() { Name = ClientName.Text, Phone = Phone.Text, Remarks = Remarks.Text, Day = Day.Date, Hour = Day.Hour, State = Remarks.Text == string.Empty ? 1 : 2, Products = OrderedProducts, Number = LocalClient.Number }); } else { //new client await DataHolder.SaveNewClient(new Client() { Name = ClientName.Text, Phone = Phone.Text, Remarks = Remarks.Text, Day = Day.Date, Hour = Day.Hour, State = Remarks.Text == string.Empty ? 1 : 2, Products = OrderedProducts, Number = DataHolder.Clients.Any() ? DataHolder.Clients.Last().Number + 1 : 0 }); } ClientName.Text = ""; Phone.Text = ""; Remarks.Text = ""; OrderedProducts.Clear(); ProductsMenu.ItemsSource = Categories; ((Grid)this.Parent).Children.Remove(this); } }
public void ReturnToWarehouse(object sender, BakeryEventArgs args) { var bakeryProduct = _context.BakeryProducts.FirstOrDefault(bp => bp.Name == args.OrderedBakeryProduct.Name); if (bakeryProduct == null) { var newBakeryProduct = args.OrderedBakeryProduct.ToModel(); _context.BakeryProducts.Add(newBakeryProduct); } else { bakeryProduct.Quantity += args.OrderedBakeryProduct.Quantity; } _context.SaveChanges(); var bakeryProductView = BakeryProducts.FirstOrDefault(bp => bp.Name == args.OrderedBakeryProduct.Name); if (bakeryProductView == null) { BakeryProducts.Add(args.OrderedBakeryProduct); } else { bakeryProductView.Quantity += args.OrderedBakeryProduct.Quantity; } var orderedItem = OrderedProducts.FirstOrDefault(bp => bp.Name == args.OrderedBakeryProduct.Name); OrderedProducts.Remove(orderedItem); RaisePropertyChanged("BakeryProducts"); RaisePropertyChanged("OrderedProducts"); LoadProducts(); }
public void ProcessOrder(Cart cart, Order order) { EFDbContext context = new EFDbContext(); decimal totalCost = 0; foreach (var cartLine in cart.Lines) { totalCost += (cartLine.Product.Price * cartLine.Quantity); } order.TotalCost = totalCost; order.Status = "NEW"; order.Date = DateTime.Now; context.Orders.Add(order); context.SaveChanges(); foreach (var line in cart.Lines) { // Добавить метод добавления OrderedProducts product = new OrderedProducts() { OrderId = order.Id, ProductId = line.Product.Id, Quantity = line.Quantity, //Product = line.Product }; //order.OrderedProducts.Add(product); context.OrderedProducts.Add(product); } context.SaveChanges(); }
public IActionResult Index() { { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:58639"); client.DefaultRequestHeaders.Accept.Add( new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); OrderedProducts sales = new OrderedProducts() { CustomerId = 1, OrderDate = DateTime.Now, Products = DemoProductContainer.GetProducts() }; string json = JsonConvert.SerializeObject(sales); HttpContent content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync("api/order", content).Result; if (response.IsSuccessStatusCode) { string[] data = (string[])response.Content.ReadAsAsync(typeof(string[])).Result; // return Invoice(sales, data); CustomerDetails details = new CustomerDetails(); Customer customer = details.GetCustomerById(sales.CustomerId); ViewBag.customer = customer.CustomerMailId; ViewBag.OrderInvoice = data; ViewBag.customer = customer; ViewBag.orderdate = sales.OrderDate; return(View("Invoice", sales)); } ViewBag.error = response.ReasonPhrase; return(View("Error")); } }
public void UpdateOrderedProducts(object sender, BakeryEventArgs args) { var orderedProduct = args.OrderedBakeryProduct; orderedProduct.AlwaysTrue = true; OrderedProducts.Add(orderedProduct); RaisePropertyChanged("OrderedProducts"); }
private void RefreshProducts(ICollection <Product> products) { OrderedProducts.Clear(); foreach (var item in products) { OrderedProducts.Add(item); } }
public IActionResult Invoice(OrderedProducts products, string[] data) { CustomerDetails details = new CustomerDetails(); Customer customer = details.GetCustomerById(products.CustomerId); ViewBag.OrderInvoice = data; ViewBag.customer = customer; return(View("Invoice", products)); }
public IActionResult DoService() { double totalAmount = 0; string stringszz = ""; OrderedProducts defaultOrder = new OrderedProducts(); double mainPrice = Double.Parse(Request.Form["etoUngPriceDati"].ToString()); defaultOrder.Price = mainPrice; totalAmount += mainPrice; defaultOrder.ProductName = Request.Form["description"].ToString(); defaultOrder.Quantity = 1; defaultOrder.DateOrdered = DateTime.Now; int serviceId = Int32.Parse(Request.Form["sid"].ToString()); int reqId = Int32.Parse(Request.Form["id"].ToString()); defaultOrder.TransactionID = _transactionRepo.FindTransaction(a => a.RequestId == reqId).TransactionKey; _orderedRepository.Create(defaultOrder); for (int i = 1; i <= Int32.Parse(Request.Form["numberOfQuotation"].ToString()); i++) { string serachable = "q" + i; if (Request.Form.Keys.Any(k => k == serachable)) { OrderedProducts orp = new OrderedProducts(); double singlePrice = Double.Parse(Request.Form["q" + i].ToString()); orp.Price = singlePrice; orp.ProductName = Request.Form["l" + i].ToString(); orp.Quantity = Int32.Parse(Request.Form["stock" + i].ToString());; totalAmount += singlePrice * orp.Quantity; orp.DateOrdered = DateTime.Now; int service = Int32.Parse(Request.Form["sid"].ToString()); orp.TransactionID = _transactionRepo.FindTransaction(a => a.RequestId == reqId).TransactionKey; _orderedRepository.Create(orp); } // stringszz += $" {Request.Form["sid"]} : {Request.Form["l" + i]} {Request.Form["q" + i]} <br>"; } var request = _requestRepo.GetIdBy(Int32.Parse(Request.Form["id"].ToString())); request.Status = "accepted"; request.Price = (float)totalAmount; var trans = _transactionRepo.GetIdBy(defaultOrder.TransactionID); trans.PaymentStatus = "On-going"; trans.TotalPrice = totalAmount; trans.ImageString = null; _transactionRepo.Update(trans); _requestRepo.Update(request); return(Content("total" + totalAmount)); }
public decimal GetPercent(int ProductID) { var pCost = OrderedProducts.Where(x => x.ProductID == ProductID).Sum(x => x.Price * x.Amount); var sum = TotalSum; if (sum == 0) { return(0); } return(pCost * 100 / sum); }
private async void FinalizeSale() { if (TotalPrice <= ScannedCustomer.Balance) { foreach (Product p in OrderedProducts) { Transfer t = new Transfer(); Sales s = new Sales(); s.Amount = 1; s.CustomerId = ScannedCustomer.Barcode; s.ProductId = p.Id; s.RegisterId = 5; s.Timestamp = DateTime.Now; s.TotalPrice = p.Price; t.Sender = ScannedCustomer; t.Receiver = s; try { string input = JsonConvert.SerializeObject(t); using (HttpClient client = new HttpClient()) { HttpResponseMessage response = await client.PutAsync("http://localhost:41983/api/ProductRegister/", new StringContent(input, Encoding.UTF8, "application/json")); if (response.IsSuccessStatusCode) { } else { MessageBox.Show("There were no transactions"); } } } catch (Exception ex) { MessageBox.Show("Order failed"); } } ScannedCustomer = null; CustomerScanned = false; OrderedProducts.Clear(); Customers.Clear(); GetCustomers(); TotalPrice = 0; DifferenceTotalBalance = 0; } else { MessageBox.Show("Customers balance is insufficient"); } }
public void GetToPreviousWindow() { if (OrderedProducts.Any()) { MessageBox.Show("You cannot leave this window while ordered products is not empty", "Exception", MessageBoxButton.OK, MessageBoxImage.Warning); return; } else { var menu = new MenuView(); menu.Show(); CloseAction(); } }
private void AddProduct(int i) { ClickedProduct = (from p in Products where p.Id == i select p).First(); try { OrderedProducts.Add(ClickedProduct); TotalPrice += ClickedProduct.Price; DifferenceTotalBalance = ScannedCustomer.Balance - TotalPrice; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public IActionResult AddToDatabase([FromBody] OrderedProducts products) { string[] result; try { result = data.PostForOrderInvoice(products); return(Ok(result)); } catch (Exception exception) { ModelStateDictionary dictionary = new ModelStateDictionary(); dictionary.AddModelError("Error", exception.Message); return(BadRequest(dictionary)); } }
public OrderedProducts Add(string orderId, string productCode, string productName, string packegesCount, string packegesWeight) { var product = _context.Products.FirstOrDefault(x => x.ProductCode == productCode && x.Name == productName); var orderedProduct = new OrderedProducts() { OrderedPackagesCount = int.Parse(packegesCount), OrderedPackagesWeight = decimal.Parse(packegesWeight), ProductId = product.Id, OrderId = orderId, // TODO to find current orderId }; _context.OrderedProducts.Add(orderedProduct); _context.SaveChanges(); return(orderedProduct); }
public OrderedProducts Include(string orderId, string productCode, string productName, string packegesCount, string packegesWeight, string lot) { var product = _context.Products.First(x => x.ProductCode == productCode && x.Name == productName); var lotId = _context.Lots.First(x => x.SerialNumber == lot).Id; var orderedProduct = new OrderedProducts() { OrderedPackagesCount = int.Parse(packegesCount), OrderedPackagesWeight = decimal.Parse(packegesWeight), ProductId = product.Id, OrderId = orderId, LotId = lotId, }; _context.OrderedProducts.Add(orderedProduct); _context.SaveChanges(); return(orderedProduct); }
public void ProcessOrderedItems() { if (OrderedProducts.Any()) { var sales = new List <Sale>(); foreach (var item in OrderedProducts) { var sale = new Sale { Amount = item.Quantity * item.Price, Name = item.Name, TransactionDate = DateTime.UtcNow, UomType = item.UomType, Quantity = item.Quantity }; sales.Add(sale); } _context.Sales.AddRange(sales); _context.SaveChanges(); var receiptView = new ReceiptView(); var viewModel = new ReceiptViewModel(); receiptView.DataContext = viewModel; if (viewModel.CloseAction == null) { viewModel.CloseAction = new Action(receiptView.Close); } ((ReceiptViewModel)receiptView.DataContext).LoadOrderedProducts(OrderedProducts.ToModelObservableCollection()); receiptView.ShowDialog(); OrderedProducts.Clear(); RaisePropertyChanged("OrderedProducts"); } else { MessageBox.Show("There is no item to order", "Exception", MessageBoxButton.OK, MessageBoxImage.Warning); return; } }
private void Button_Click(object sender, RoutedEventArgs e) { switch (state) { case 0: SelectedProducts = new ObservableCollection <Product>(); foreach (var products in DataHolder.Products) { if (products.Category == ((Product)((Button)sender).DataContext).Category) // { SelectedProducts.Add(products); } } ProductsMenuBack.IsEnabled = true; ProductsMenu.ItemsSource = SelectedProducts; state++; break; case 1: ProductsMenu.ItemsSource = Categories; ProductsMenuBack.IsEnabled = false; var prod = (Product)((Button)sender).DataContext; var query = OrderedProducts.FirstOrDefault(op => op.Product == prod); if (query != null) { query.Quantity++; } else { OrderedProducts.Add(new OrderedProduct() { Product = prod, Quantity = 1, Sliced = false, Slicable = prod.Category == "Pain" ? true : false }); } state--; break; } }
private void RemoveProduct(Product obj) { try { if (OrderedProducts.Count == 1) { OrderedProducts.Clear(); TotalPrice -= obj.Price; DifferenceTotalBalance = 0; } else { OrderedProducts.Remove(obj); TotalPrice -= obj.Price; DifferenceTotalBalance = ScannedCustomer.Balance - TotalPrice; } } catch (Exception) { MessageBox.Show("You have to select a product to return"); } }
private void button2_Click(object sender, EventArgs e) { using (var context = new FactoryContext()) { var order = new Order(); order.Customer = context.Users.Single(u => u.Login == user_.Login && u.Password == user_.Password); order.Date = DateTime.Now; order.Stage = "новый"; order.Price = 0; foreach (DataGridViewRow row in dataGridView1.Rows) { try { var prods = new OrderedProducts(); prods.ProductId = row.Cells[0].Value.ToString(); prods.Order = order; int count; if (Int32.TryParse(row.Cells[2].Value.ToString(), out count)) { prods.Quantity = count; } else { MessageBox.Show("Неправильно указано количество изделий"); return; } context.OrderedProducts.Add(prods); order.Price += context.Products.Single(p => p.ProductId == prods.ProductId).Price; } catch (Exception ex) { continue; } } context.Orders.Add(order); context.SaveChanges(); MessageBox.Show("Заказ успешно создан"); } }
public IActionResult AcceptService(int id, float price, double c1, double c2, double c3, double c4, double c5, double c6, double c7, double c8, double c9, string description, double prodPrice) { double totalAmount = price; OrderedProducts defaultOrder = new OrderedProducts(); defaultOrder.Price = price; defaultOrder.ProductName = description; defaultOrder.Quantity = 1; defaultOrder.DateOrdered = DateTime.Now; defaultOrder.TransactionID = _transactionRepo.FindTransaction(a => a.ServiceID == id).TransactionKey; _orderedRepository.Create(defaultOrder); if (c9 != 0) { } return(RedirectToAction("List", "Request")); }
public void Clear() { OrderedProducts.Clear(); }
private void Delete_Click(object sender, RoutedEventArgs e) { OrderedProduct data = (OrderedProduct)((Button)sender).DataContext; OrderedProducts.Remove(data); }
public async Task <ActionResult> OrderProducts() {//hier betaling uitvoeren. met id kan hij pas de betaling uitvoeren var o_aanhef = HttpContext.Request.Query["o_aanhef"].ToString(); var o_name = HttpContext.Request.Query["o_name"].ToString(); var o_postal = HttpContext.Request.Query["o_postal"].ToString(); var o_address = HttpContext.Request.Query["o_address"].ToString(); var o_number = HttpContext.Request.Query["o_number"].ToString(); var prijs = HttpContext.Request.Query["prijs"].ToString(); var paymentId = HttpContext.Request.Query["paymentId"].ToString(); var PayerID = HttpContext.Request.Query["PayerID"].ToString(); var environment = new SandboxEnvironment("ATAmdaFGY2Pz6CH83fmdK8OaXu2Wd8b9fLDyuU8X3SNiAzvu2_Ks4IU3wPiNbpE74nWIkhb4jN_7pz9E", "EOksjziNOaGEYh-OroCWTFT_EKDlqJEIpsrZLMtUhmYNxgDZ_v6KGwyL1MFcWJ-dfv97PApRKroAAT0g"); var Pay_client = new PayPalHttpClient(environment); PayPal.v1.Payments.PaymentExecuteRequest request = new PayPal.v1.Payments.PaymentExecuteRequest(paymentId); request.RequestBody(new PayPal.v1.Payments.PaymentExecution() { PayerId = PayerID }); BraintreeHttp.HttpResponse response = await Pay_client.Execute(request); if (o_aanhef == null) { o_aanhef = ""; } var db = new ModelContext(); var UserId = HttpContext.Session.GetInt32("UID"); int?UserIdResult = 0; if (UserId == null) { UserId = HttpContext.Session.GetInt32("SessionAccountId"); UserIdResult = HttpContext.Session.GetInt32("SessionAccountId"); } else { UserIdResult = (from s in db.Account where s.id == UserId select s.id).Single(); } var ShoppingCartResult = from s in db.ShoppingCart where s.AccountId == UserId select s; Console.WriteLine(o_name + o_postal + o_address + o_number); //MaxId //nieuwe bestelling aanmaken int MaxId = 0; var result = from s in db.Order select s.Id; if (!result.Any()) { } else { MaxId = result.Max(); } Order order = new Order { Id = MaxId + 1, AccountId = UserIdResult, Datum = DateTime.Now, Prijs = prijs, OrderStatus = "Verwerkt", }; db.Order.Add(order); db.SaveChanges(); foreach (var item in ShoppingCartResult) { int MaxOrderedProductsId = 0; var resultt = from s in db.OrderedProducts select s.Id; if (!resultt.Any()) { } else { MaxOrderedProductsId = resultt.Max(); } OrderedProducts orderedProducts = new OrderedProducts { Id = MaxOrderedProductsId + 1, OrderId = MaxId + 1, ProductId = item.VoorraadId, Quantity = item.Quantity, }; db.OrderedProducts.Add(orderedProducts); db.SaveChanges(); var voorraad = (from v in db.Voorraad where v.Id == item.VoorraadId select v).ToList(); foreach (var item2 in voorraad) { var NewQuantity = item2.Kwantiteit - item.Quantity; item2.Kwantiteit = NewQuantity; } db.SaveChanges(); } var deleteShoppingCart = (from d in db.ShoppingCart where d.AccountId == UserIdResult select d).ToList(); foreach (var item in deleteShoppingCart) { db.ShoppingCart.Remove(item); db.SaveChanges(); } var check = (from s in db.ShoppingCart where s.AccountId == UserId select s).ToList(); //Bestellingsmail voor Petgoods4All MailMessage mail = new MailMessage(); SmtpClient client = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); mail.To.Add("*****@*****.**"); mail.Subject = "Order: " + MaxId + 1; mail.Body = "Order placed from user " + UserId + ".\n"; foreach (var item in check) { var item2 = (from s in db.Voorraad where item.VoorraadId == s.Id select s.Naam).Single(); mail.Body = mail.Body + "Product: " + item2 + "\n"; } mail.Body = mail.Body + "aanhef: " + o_aanhef + "\n" + "adres: " + o_address + "\n" + "postcode: " + o_postal + "\n" + "huisnummer: " + o_number + "\n" + "naam: " + o_name + "\n"; client.Port = 587; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "adminpetgoods4all"); client.EnableSsl = true; client.Send(mail); Console.WriteLine("Mail sent to Petgoods4all"); // Einde Bestellingsmail voor Petgoods4All //Bevestigingsmail besteller string UserEmail = (from s in db.Account where s.id == UserId select s.email).Single(); mail.To.Clear(); mail.To.Add(UserEmail); mail.Subject = "Order: " + MaxId + 1; mail.Body = "Geachte " + o_aanhef + " " + o_name + ", \n" + "Bedankt voor uw bestelling.\n" + "De producten komen uw kant op.\n" + "adres:" + o_address + "\n" + "postcode: " + o_postal + "\n" + "Huisnummer: " + o_number + "\n" + "Veel dierenplezier met de producten!\n Met vriendelijke groeten,\n\n Petgoods4All"; client.Port = 587; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "adminpetgoods4all"); client.EnableSsl = true; client.Send(mail); Console.WriteLine("KlantMail sent "); var AnonymousUser = HttpContext.Session.GetInt32("SessionAccountId"); if (AnonymousUser == null) { return(OrderHistory()); } else { //var delUser = (from s in db.Account where s.id == UserId select s).Single(); //db.Account.Remove(delUser); //db.SaveChanges(); int?randomAccountIdSum; var AccountResult = from r in db.Account select r.id; HttpContext.Session.Remove("SessionAccountId"); if (AccountResult == null) { randomAccountIdSum = AccountResult.Max() + 1; } else { randomAccountIdSum = 1; } int randomAccountId = randomAccountIdSum.GetValueOrDefault(1); HttpContext.Session.SetInt32("SessionAccountId", randomAccountId); return(Redirect("http://localhost:56003/Order/Bedankt")); } }
public TTOutMessage(string indent, string connectionString) { Products = new OrderedProducts(indent, connectionString); }
public ActionResult ViewOrders() { List <OrderModel> AllOrdersModel = new List <OrderModel>(); //List<ProductModel> AllProducts = new List<ProductModel>(); ListProdCat AllCategorys = new ListProdCat(); OrderModel ordersModel = new OrderModel(); ProductModel FirstProduct = new ProductModel { Product_ID = 1, Product_Name = "Laptop1", Product_Price = 300, Product_Category = "2", Product_CatName = AllCategorys.CategoryLookup[1] }; ProductModel SecondProduct = new ProductModel { Product_ID = 2, Product_Name = "Food1", Product_Price = 200, Product_Category = "1", Product_CatName = AllCategorys.CategoryLookup[0] }; ProductModel ThirdProduct = new ProductModel { Product_ID = 3, Product_Name = "Food1", Product_Price = 400, Product_Category = "1", Product_CatName = AllCategorys.CategoryLookup[0] }; ProductModel ForthProduct = new ProductModel { Product_ID = 4, Product_Name = "Food2", Product_Price = 150, Product_Category = "1", Product_CatName = AllCategorys.CategoryLookup[0] }; ProductModel FifthProduct = new ProductModel { Product_ID = 5, Product_Name = "Game1", Product_Price = 250, Product_Category = "3", Product_CatName = AllCategorys.CategoryLookup[2] }; OrderedProducts firstOrderPorduct = new OrderedProducts { Order_Id = 2000001, Product_Quantity = 3, Ordproduct = FirstProduct }; OrderedProducts SecondOrderProduct = new OrderedProducts { Order_Id = 2000001, Product_Quantity = 4, Ordproduct = SecondProduct }; OrderedProducts ThirdOrderProduct = new OrderedProducts { Order_Id = 3000001, Product_Quantity = 5, Ordproduct = ThirdProduct }; OrderedProducts ForthOrderProduct = new OrderedProducts { Order_Id = 3000001, Product_Quantity = 5, Ordproduct = ForthProduct }; ordersModel.ListOrderedProducts.Add(firstOrderPorduct); ordersModel.ListOrderedProducts.Add(SecondOrderProduct); ordersModel.ListOrderedProducts.Add(ThirdOrderProduct); ordersModel.ListOrderedProducts.Add(ThirdOrderProduct); AllOrdersModel.Add(ordersModel); return(View(AllOrdersModel)); }