public void DisplayAfterDeletion1(int num)
        {
            try
            {
                ProductDetailsFill obj = new ProductDetailsFill();

                List <ProductGroup> productgroup = obj.ProductGroupFill();
                List <ProductInfo>  productinfo  = obj.ProductFill();

                List <ProductInfo> pNew = obj.ProductDelete1(productinfo, num);

                foreach (ProductGroup item1 in productgroup)
                {
                    foreach (ProductInfo item2 in productinfo)
                    {
                        if (item1.ID == item2.GroupID)
                        {
                            Console.WriteLine("Product Group Name: " + item1.Name + " || Product Name: " + item2.Name + " || Product Description: " + item2.Description + " || Product Rate: " + item2.rate);
                        }
                    }
                }
            }catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
        public void DisplayFound(string str_keyword)
        {
            if (str_keyword == null)
            {
                Console.WriteLine("Please enter a string!");
            }
            else
            {
                try
                {
                    ProductDetailsFill obj = new ProductDetailsFill();

                    List <ProductGroup> productgroup = obj.ProductGroupFill();
                    List <ProductInfo>  productinfo  = obj.ProductFill();

                    var res = productinfo.Where(p => p.Name.ToUpper().Contains(str_keyword.ToUpper()));

                    foreach (ProductGroup item1 in productgroup)
                    {
                        foreach (ProductInfo item2 in res)
                        {
                            if (item1.ID == item2.GroupID)
                            {
                                Console.WriteLine("Product Group Name: " + item1.Name + " || Product Name: " + item2.Name + " || Product Description: " + item2.Description + " || Product Rate: " + item2.rate);
                            }
                        }
                    }
                }catch (Exception ex) {
                    Console.WriteLine(ex.Message);
                }
            }
        }
        public void DisplayAfterDeletion4(string delete_name)
        {
            try
            {
                ProductDetailsFill obj = new ProductDetailsFill();

                List <ProductGroup> productgroup = obj.ProductGroupFill();
                List <ProductInfo>  productinfo  = obj.ProductFill();
                if (productinfo.Any(product => product.Name == delete_name))
                {
                    List <ProductInfo> pNew = obj.ProductDelete4(productinfo, delete_name);
                    foreach (ProductGroup item1 in productgroup)
                    {
                        foreach (ProductInfo item2 in productinfo)
                        {
                            if (item1.ID == item2.GroupID)
                            {
                                Console.WriteLine("Product Group Name: " + item1.Name + " || Product Name: " + item2.Name + " || Product Description: " + item2.Description + " || Product Rate: " + item2.rate);
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Enter a valid product name to be deleted");
                }
            }catch (Exception) {
                Console.WriteLine("please enter valid input");
            }
        }
Beispiel #4
0
        public IEnumerable <ProductInfo> ProductSort(List <ProductInfo> productinfo)
        {
            ProductDetailsFill obj = new ProductDetailsFill();

            productinfo.Sort(obj);
            return(productinfo);
        }
        public static int Find(string str)
        {
            try
            {
                ProductDetailsFill productdetailsfill = new ProductDetailsFill();

                List <ProductGroup> productgrouplist = productdetailsfill.ProductGroupFill();

                foreach (ProductGroup item in productgrouplist)
                {
                    if (item.Name == "Dairy" && item.Name == str)
                    {
                        return(1);
                    }
                    if (item.Name == "Beverages" && item.Name == str)
                    {
                        return(2);
                    }
                    if (item.Name == "Detergents" && item.Name == str)
                    {
                        return(3);
                    }
                    if (item.Name == "Groceries" && item.Name == str)
                    {
                        return(4);
                    }
                }
            }catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
            return(0);
        }
        public void displaySortedProducts()
        {
            try
            {
                ProductDetailsFill obj = new ProductDetailsFill();

                List <ProductGroup>       productgroup = obj.ProductGroupFill();
                List <ProductInfo>        productinfo  = obj.ProductFill();
                IEnumerable <ProductInfo> p            = obj.ProductSort(productinfo);

                foreach (ProductGroup item1 in productgroup)
                {
                    foreach (ProductInfo item2 in p)
                    {
                        if (item1.ID == item2.GroupID)
                        {
                            Console.WriteLine("Product Group Name: " + item1.Name + " || Product Name: " + item2.Name + " || Product Description: " + item2.Description + " || Product Rate: " + item2.rate);
                        }
                    }
                }
            }catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }