public static string DeleteProduct(List <int> arrid) { try { return(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(new { Status = ProductInfo.DeleteProduct(HttpContext.Current.User.Identity.Name, arrid) })); } catch (Exception e) { return(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(new { Status = false, Data = e.Message })); } }
static void Main(string[] args) { ProductInfo productInfo = new ProductInfo(); do { Console.WriteLine("1.Add New Product"); Console.WriteLine("2.Deleting Currently Searched Product"); Console.WriteLine("3.Search Product"); Console.WriteLine("4.Save the New Product"); Console.WriteLine("5.Exit"); Console.WriteLine("Enter your Choice"); int ch = int.Parse(Console.ReadLine()); switch (ch) { case 1: { Product p = GetDetails(); productInfo.AddProduct(p); } break; case 2: { Console.WriteLine("Enter Produt Id"); int Id = int.Parse(Console.ReadLine()); if (productInfo.DeleteProduct(Id)) { Console.WriteLine("Product Removed."); } else { Console.WriteLine("Invalid Id"); } } break; case 3: { Console.WriteLine("Enter Product No"); string pno = Console.ReadLine(); Product product = productInfo.GetProduct(pno); if (product != null) { Console.WriteLine("Price: " + product.ProductName); Console.WriteLine("Price: " + product.Price); Console.WriteLine("Availability: " + product.Stock); } else { Console.WriteLine("Product Not Exist"); } } break; case 4: ArrayList products = productInfo.GetProducts(); foreach (Product p in products) { Console.WriteLine("{0} {1} {2} {3}", p.ProductId, p.ProductName, p.Price, p.Stock); } bool a = productInfo.SortedOrder(); if (a) { ArrayList products1 = productInfo.GetProducts(); foreach (Product p in products1) { Console.WriteLine("{0} {1} {2} {3}", p.ProductId, p.ProductName, p.Price, p.Stock); } } break; case 5: { Environment.Exit(0); } break; } } while (true); }