Example #1
0
        public ActionResult Register(Register register)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    ConnectUpdate udb = new ConnectUpdate();
                    hackathonunitecEntities db = udb.getDB();
                    user User = new user();
                    User.email = register.email;
                    Crypto crypto = new Crypto(register.password);
                    User.password = crypto.GetHash();
                    User.firstname = register.firstname;
                    User.lastname = register.lastname;
                    User.active = true;
                    user_role User_Role = new user_role();
                    User_Role.roleid = 2;
                    User_Role.active = true;
                    User.user_role.Add(User_Role);
                    db.user.Add(User);
                    db.SaveChanges();
                    return View("Thanks");
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                    return View();

                }
            }
            else
            {
                return View();
            }
        }
Example #2
0
        public ActionResult Login(Login login)
        {
            if (ModelState.IsValid)
            {
                ConnectUpdate udb = new ConnectUpdate();
                hackathonunitecEntities db = udb.getDB();

                Crypto crypto = new Crypto(login.password);
                 string password = crypto.GetHash();
                var users =  db.user.Where(p => p.email == login.email && p.password == password );
                int coun = users.Count();
                if (users.Count() == 1)
                {
                    Session["email"] = login.email;
                    return View("Index");
                }
                else
                {
                    ModelState.AddModelError("email", "email or Password not valid");
                    return View();
                }
            }
            else
            {

                return View();
            }
        }
Example #3
0
        public ActionResult Role()
        {
            ConnectUpdate udb = new ConnectUpdate();
            hackathonunitecEntities db = udb.getDB();
            List<role> roles = db.role.ToList();
            string json = "";

            for (int i = 0; i < roles.Count; i++)
            {
                if (!json.Equals("")) { json += ","; }
                json += "{" + String.Format("\"id\":\"{0}\",\"role\":\"{1}\",\"status\":\"{2}\",\"option\":\"{3}\"", roles[i].roleid, roles[i].rolname, roles[i].active, 1) + "}";

            }

             json = "{\"draw\": 1,\"recordsTotal\": 1,\"recordsFiltered\": 1,\"data\": ["+json+"]}";
            return Content(json);
        }