Exemple #1
0
        public void FindByNameClient()
        {
            clientsManagment.Load();
            Client cli = new Client("Nik", "ghhghg", 1100);

            clientsManagment.Insert(cli);
            clientsManagment.SaveChanges();
            clientsManagment.Load();
            clientsManagment.Find(x => x.Email == "Nik");
            Assert.AreEqual(cli.Money, clientsManagment.Find(x => x.Email == "Nik").ElementAt(1).Money);
        }
Exemple #2
0
 private void SaveIt()
 {
     clients.SaveChanges();
     clients.Load();
     services.SaveChanges();
     services.Load();
 }
        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());
            }
        }
        public ActionResult Registration(string email, string password)
        {
            ClientsManagment var = new ClientsManagment();

            // Shop.RegistryClient(email, password, 510);
            var.unitOfWork.Clients.Insert(new Client(email, password, 5120));
            var.SaveChanges();
            var.Load();
            ViewBag.Message = "Succesfully registred";
            return(View("Index"));
        }