示例#1
0
        static void Main(string[] args)
        {
            ProductManager producManager = new ProductManager(new InMemoryDal());

            foreach (var p in producManager.GetAll())
            {
                Console.WriteLine(p.BrandId + " " + p.Id + " " + p.Description);
            }
            Console.WriteLine("*******");
            producManager.Add(new Product {
                BrandId = 5, ColorId = 7, DailyPrice = 5000, Description = "Ultra Lüks", Id = 8, ModelYear = 2021
            });
            foreach (var p in producManager.GetAll())
            {
                Console.WriteLine(p.BrandId + " " + p.Id + " " + p.Description);
            }

            Console.WriteLine("*******");

            producManager.Delete(new Product {
                Id = 3
            });
            foreach (var p in producManager.GetAll())
            {
                Console.WriteLine(p.BrandId + " " + p.Id + " " + p.Description);
            }

            Console.WriteLine("*******");
            producManager.Update(new Product {
                Id = 8, Description = "değişti"
            });
            foreach (var p in producManager.GetAll())
            {
                Console.WriteLine(p.BrandId + " " + p.Id + " " + p.Description);
            }

            Console.WriteLine("*******");
            foreach (var p in producManager.GetByBrandId(2))
            {
                Console.WriteLine(p.BrandId + " " + p.Id + " " + p.Description);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            ProductManager productManager = new ProductManager(new EfProductDal(), new CategoryManager(new EfCategoryDal()));

            //var result = productManager.GetAll();

            //if (result.Success)
            //{
            //    foreach (var item in result.Data)
            //    {
            //        Console.WriteLine(item.ProductName + "\t\t\t\t" + result.Message);
            //    }
            //}
            //else
            //{
            //    Console.WriteLine(result.Message);
            //}

            //CategoryManager category = new CategoryManager(new EfCategoryDal());
            //Console.WriteLine(category.GetById(1).CategoryName);
            var result = productManager.getById(77).Data;

            productManager.Delete(result);
        }