public ActionResult nAdetUrunGet(string categoryName,int count) { NAdetUrunGetModel model = new NAdetUrunGetModel(); PrepareCategoryHash categoryHash = new PrepareCategoryHash(); model.CategoryName = categoryName; model.Coun = count; categoryHash.CreateHashTableAndProductTree(); var ProductTree=(ProductGroupTree)categoryHash.GetCategoryTable[categoryName]; if (ProductTree != null) { //var productList = ProductTree.ProductHeap.GetProductByCount(count,ProductTree.TreeSize); ProductHeap heap = new ProductHeap(); ProductTree.inOrderForProductsAllProduct(ProductTree.GetRoot()); var productList = ProductTree.AllProductByCategoryName; foreach (var item in productList) { heap.insert(item); } var productsLowPrice = heap.GetProductByCount(count,ProductTree.ProductTotalSize);//get lower product by count ProductTree.DeleteProducts(ProductTree.GetRoot(), productsLowPrice.Select(x => x.ProductId).ToList());//update products in tree model.Products = productsLowPrice; foreach (var item in productsLowPrice) { Invoice invoice = new Invoice(); invoice.ProductId = item.ProductId; invoice.CustomerID = CurrentUser.CustmerID; invoice.DateTime = DateTime.Now; invoice.Approval = false; invoice.ProductNumber = 1; _checkoutService.AddInvoice(invoice);//sepete eklendi var product = _productService.GetProductByProductId(item.ProductId);//entitiy update product.ProductNumber = product.ProductNumber - 1; _productService.UpdateProduct(product); } } return View(model); }