示例#1
0
 public UserManager(UserDTO user)
 {
     currentUser = user;
     userDal     = new UserDAL(user.Email);
     productDal  = new ProductDAL(user.Email);
     responseDal = new ResponceDAL(user.Email);
 }
示例#2
0
        public static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.Default;


            string connectionString = @"Data Source=DESKTOP-EA43ILH\MSSQLSERVER02;Initial Catalog=ProductManager;Integrated Security=True";

            userDal_    = new UserDAL(connectionString);
            responceDAL = new ResponceDAL(connectionString);
            productDAL  = new ProductDAL(connectionString);


            userDal_.Add(new UserDTO()
            {
                FullName = "f", Login = "******", Password = "******"
            });


            uint isLogIn = LogIn();

            while (currentUser.Id != 0)
            {
                Console.WriteLine("\n\n What do you want to DO?");
                Console.WriteLine("\ntype 'l' to get List of entities");
                Console.WriteLine("type 's' to Sort entity");
                Console.WriteLine("type 'r' to all entitys by user");
                Console.WriteLine("type 'f' to Find entity");
                if (isLogIn == 2)
                {
                    Console.WriteLine("type 'a' to Add entity");
                    Console.WriteLine("type 'r' to make responce");
                }
                Console.WriteLine("type 'o' to logOut");
                Console.WriteLine("type 'q' to Quit");
                try
                {
                    char c = char.Parse(Console.ReadLine());

                    switch (c)
                    {
                    case 'l':     //show list of entities
                    {
                        Console.WriteLine("\nList of all entity:");
                        PrintAll();
                    }
                    break;

                    case 's':     //
                    {
                        Console.WriteLine("\nSorted by product name:");
                        PrintSorted();
                    }
                    break;

                    case 'a':     //create new entity
                    {
                        Console.WriteLine("Add:");
                        AddProduct();
                    }
                    break;

                    case 'r':     //remove entity
                    {
                        AllProductsOfUser();
                    }
                    break;

                    case 'f':
                    {
                        Console.WriteLine("Please, enter a word or letters or a price: ");         // find by Title
                        string ttl = Console.ReadLine().ToString();
                        Find(ttl);
                    }
                    break;

                    case 'o':
                    {
                        isLogIn = LogIn();
                    }
                    break;

                    case 'q':
                        return;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }