Beispiel #1
0
        private static void ActiveUser(UserRepository ur)
        {
            Console.WriteLine("Enter a specefic id to find the active User");
            var u2 = ur.ActiveUsers();

            Console.WriteLine("Id\t Name\t Email\t Location\t Address\t isActive");
            foreach (var item in u2)
            {
                Console.WriteLine(item.Id + "\t" + item.Name + "\t" + item.Email + "\t" + item.Location + "\t" + item.Address + "\t" + item.IsActive);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            applicationDB  _db            = new applicationDB();
            UserRepository initializeUser = new UserRepository();

            for (var i = 0; i < 10; i++)
            {
                user userData = new user();


                userData.name     = "Kunal" + (i + 1);
                userData.location = "Bhagalpur" + (i + 1);
                userData.address  = "Aliganj" + (i + 1);

                userData.email    = "kunal" + (i + 1) + "@gmail.com";
                userData.isActive = (i + 1) % 2 == 0 ? true : false;


                _db.users.Add(userData);
                _db.SaveChanges();
            }



            List <user> AllUserData = new List <user>();

            AllUserData = initializeUser.Users();
            Console.WriteLine("Id \t Name \t Email \t \t \tLocation \tAddress\t\tActiveStatus");
            foreach (user users in AllUserData)
            {
                Console.WriteLine(users.id + "\t" + users.name + "\t" + users.email + "\t" + users.location + "\t" + users.address + "\t  " + users.isActive);
            }



            Console.WriteLine();

            user getUser;

            Console.WriteLine("Enter the user id which you want to retrieve");
            int id = Convert.ToInt32(Console.ReadLine());

            getUser = initializeUser.GetUser(id);
            Console.WriteLine("Id \t Name \t Email \t \t \tLocation \tAddress\t\tActiveStatus");
            Console.WriteLine(getUser.id + "\t" + getUser.name + "\t" + getUser.email + "\t" + getUser.location + "\t" + getUser.address + "\t  " + getUser.isActive);



            Console.WriteLine();



            Console.WriteLine("Enter the id for User you want to Delete");
            int         delUser     = Convert.ToInt32(Console.ReadLine());
            List <user> delUserlist = new List <user>();

            delUserlist = initializeUser.DeleteUser(delUser);
            Console.WriteLine("List after deletion of User");
            Console.WriteLine("Id \t Name \t Email \t \t \tLocation \tAddress\t\tActiveStatus");
            foreach (user users in delUserlist)
            {
                Console.WriteLine(users.id + "\t" + users.name + "\t" + users.email + "\t" + users.location + "\t" + users.address + "\t  " + users.isActive);
            }



            Console.WriteLine();


            List <user> ActiveUser = new List <user>();

            ActiveUser = initializeUser.ActiveUsers();
            Console.WriteLine("Active Users in List");
            Console.WriteLine("Id \t Name \t Email \t \t \tLocation \tAddress\t\tActiveStatus");
            foreach (user users in ActiveUser)
            {
                Console.WriteLine(users.id + "\t" + users.name + "\t" + users.email + "\t" + users.location + "\t" + users.address + "\t  " + users.isActive);
            }



            Console.WriteLine();
            Console.WriteLine("Enter Users Details you want to add in the list");
            user addUser = new user();

            Console.WriteLine("Enter User Name");
            addUser.name = Console.ReadLine();

            Console.WriteLine("Enter User Email");
            addUser.email = Console.ReadLine() + "\t";

            Console.WriteLine("Enter User Location");
            addUser.location = Console.ReadLine();

            Console.WriteLine("Enter User Address");
            addUser.address = Console.ReadLine() + "\t";

            Console.WriteLine("Enter User Activity Status");
            addUser.isActive = Convert.ToBoolean(Console.ReadLine());

            List <user> UserListAfterAddition = new List <user>();

            UserListAfterAddition = initializeUser.AddUser(addUser);

            Console.WriteLine("Id \t Name \t Email \t \t \tLocation \tAddress\t\tActiveStatus");
            foreach (user users in UserListAfterAddition)
            {
                Console.WriteLine(users.id + "\t" + users.name + "\t" + users.email + "\t" + users.location + "\t" + users.address + "\t  " + users.isActive);
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            UsersDbContext _db            = new UsersDbContext();
            UserRepository initializeUser = new UserRepository();

            for (var i = 0; i < 10; i++)
            {
                User userData = new User();

                userData.Name     = "Person1" + (i + 1);
                userData.Location = "Location1" + (i + 1);
                userData.Address  = "Address1" + (i + 1);

                userData.Email    = "person" + (i + 1) + "@gmail.com";
                userData.IsActive = (i + 1) % 2 == 0 ? true : false;
                _db.users.Add(userData);
                _db.SaveChanges();
            }

            List <User> AllUsers = new List <User>();

            AllUsers = initializeUser.Users();
            foreach (User users in AllUsers)
            {
                Console.WriteLine("Id:\t" + users.Id + "Name\t" + users.Name + "Email\t" + users.Email + "Location\t" + users.Location + "Address\t" + users.Address + "ActiveStatus\t" + users.IsActive);
            }

            User GetUser;

            Console.WriteLine("Enter the user id");

            int id = Convert.ToInt32(Console.ReadLine());

            GetUser = initializeUser.GetUser(id);

            Console.WriteLine("Id:\t" + GetUser.Id + "Name\t" + GetUser.Name + "Email\t" + GetUser.Email + "Location\t" + GetUser.Location + "Address\t" + GetUser.Address + "ActiveStatus\t" + GetUser.IsActive);

            Console.WriteLine("Enter the id to Delete");

            int DeleteUser = Convert.ToInt32(Console.ReadLine());

            List <User> DeleteUserList = new List <User>();

            DeleteUserList = initializeUser.DeleteUser(DeleteUser);

            Console.WriteLine("List after deletion");

            Console.WriteLine("Id \t Name \t Email \t \t \tLocation \tAddress\t\tActiveStatus");

            foreach (User users in DeleteUserList)
            {
                Console.WriteLine("Id:\t" + users.Id + "Name\t" + users.Name + "Email\t" + users.Email + "Location\t" + users.Location + "Address\t" + users.Address + "ActiveStatus\t" + users.IsActive);
            }

            Console.WriteLine();

            List <User> ActiveUser = new List <User>();

            ActiveUser = initializeUser.ActiveUsers();

            Console.WriteLine("Active Users in List");

            Console.WriteLine("Id \t Name \t Email \t \t \tLocation \tAddress\t\tActiveStatus");

            foreach (User users in ActiveUser)
            {
                Console.WriteLine("Id:\t" + users.Id + "Name\t" + users.Name + "Email\t" + users.Email + "Location\t" + users.Location + "Address\t" + users.Address + "ActiveStatus\t" + users.IsActive);
            }

            Console.WriteLine("Enter Users Details to add");

            User addUser = new User();

            Console.WriteLine("Enter User Name");
            addUser.Name = Console.ReadLine();

            Console.WriteLine("Enter User Email");
            addUser.Email = Console.ReadLine() + "\t";

            Console.WriteLine("Enter User Location");
            addUser.Location = Console.ReadLine();

            Console.WriteLine("Enter User Address");
            addUser.Address = Console.ReadLine() + "\t";

            Console.WriteLine("Enter User Activity Status");
            addUser.IsActive = Convert.ToBoolean(Console.ReadLine());

            List <User> UserListAfterAddition = new List <User>();

            UserListAfterAddition = initializeUser.AddUser(addUser);

            Console.WriteLine("Id \t Name \t Email \t \t \tLocation \tAddress\t\tActiveStatus");
            foreach (User users in UserListAfterAddition)
            {
                Console.WriteLine("Id:\t" + users.Id + "Name\t" + users.Name + "Email\t" + users.Email + "Location\t" + users.Location + "Address\t" + users.Address + "ActiveStatus\t" + users.IsActive);
            }
        }