public ActionResult Submit(Admin admin)
        {
            LoginDal dal = new LoginDal();

            //Userview user = new Userview();
            String       id         = admin.Id;
            String       firstname  = admin.FirstName;
            String       lastname   = admin.LastName;
            String       permission = admin.Permmision;
            String       password   = admin.Password;
            String       username   = admin.UserName;
            List <Admin> objectus   =
                (from x in dal.Users
                 where x.Id == id
                 select x).ToList <Admin>();

            if (ModelState.IsValid)
            {
                dal.Users.Add(admin);
                dal.SaveChanges();
            }
            return(View("Adduser", admin));
        }
Exemplo n.º 2
0
        public ActionResult Submit(Login log)
        {
            LoginDal     dal       = new LoginDal();
            LoginDal     dal1      = new LoginDal();
            Userview     user      = new Userview();
            String       username1 = log.Username;
            String       password  = log.Password;
            List <Login> objectus  =
                (from x in dal.Userslogin
                 where x.Username == username1 && x.Password == password select x).ToList <Login>();

            if (ModelState.IsValid && objectus.Count == 1)
            {
                ViewBag.Current = user;
                user.Login_Use  = objectus.First <Login>();

                if (user.Login_Use.Permmision.Equals("Admin"))
                {
                    Session["User"] = username1;
                    Session["Pass"] = password;
                    Session["Per"]  = "Admin";

                    return(RedirectToRoute("Startpageadmin"));
                }
                if (user.Login_Use.Permmision.Equals("Lecturer"))
                {
                    return(View("Present2", log));
                }
                if (user.Login_Use.Permmision.Equals("Student"))
                {
                    return(View("Present3", log));
                }
            }
            dal.SaveChanges();
            dal1.SaveChanges();
            return(View("LoginPage", log));
        }