public ActionResult Login(string email, string password)
        {
            ClientsManagment  var = new ClientsManagment();
            AdminsManagment   adm = new AdminsManagment();
            ManagersManagment mag = new ManagersManagment();

            adm.Load();
            mag.Load();
            var.Load();
            var listUsers = var.GetList();

            string role = "nope";

            foreach (Client u in  listUsers)
            {
                if (u.Email.Equals(email) && u.Parol.Equals(password))
                {
                    role = "Client";
                }
            }
            var listManagers = mag.GetList();

            foreach (Manager u in listManagers)
            {
                if (u.Email.Equals(email) && u.Parol.Equals(password))
                {
                    role = "Manager";
                }
            }
            var listAdmin = adm.GetList();

            foreach (Admin u in listAdmin)
            {
                if (u.Email.Equals(email) && u.Parol.Equals(password))
                {
                    role = "Admin";
                }
            }

            if (role.Equals("Client"))
            {
                return(RedirectToAction("ClientView", new { cli = Shop.clientsManagment.Find(x => x.Email == email).ElementAt(0).Id }));
            }
            else if (role.Equals("Admin"))
            {
                return(RedirectToAction("AdminView"));
            }
            else if (role.Equals("Manager"))
            {
                return(RedirectToAction("ManagerView"));
            }
            else
            {
                ViewBag.Message = "Incorrect login or password, try again";
                return(View());
            }
        }
Exemple #2
0
        private void ShowClients()
        {
            Console.Clear();
            int i = 1;

            foreach (var a in clients.GetList())
            {
                Console.WriteLine(i + " " + a.ToString());
                i++;
            }
        }
 public IEnumerable <Client> GetAll()
 {
     return(clientMan.GetList());
 }