Esempio n. 1
0
        public string register(RegisterUser regUser)
        {
            var userstable = new userController();

            var check = userstable.getTable().FirstOrDefault<user>(c => c.user_email.Equals(regUser.email));

            if (check != null)
            {
                return "Email Already Registered";
            }

            user newUser = new user { user_fname = regUser.fname, user_email = regUser.email, user_sname = regUser.lname, user_password = regUser.password, usertype_id = 2, user_id = userstable.getTable().Count() };

            userstable.addRecord(newUser);
            return "Registered";
        }
Esempio n. 2
0
 public string login(jsonLoginUser login)
 {
     var userAccess = new userController();
     IEnumerable<user> users = userAccess.getTable();
     var user = users.FirstOrDefault<user>(c => (c.user_fname.Equals(login.name) || c.user_email.Equals(login.password) ) && c.user_password.Equals(login.password));
     if (user == null)
     {
         return "False";
     }
     var userType = new usertypeController();
     string usertype = userType.getRecord(user.usertype_id).usertype_type;
     return JsonConvert.SerializeObject(new jsonLogin {id=user.user_id,email=user.user_fname+" " + user.user_sname, type=usertype});
 }
Esempio n. 3
0
        public string GetData()
        {
            var userAccess = new userController();
            List<UserDemo> users = new List<UserDemo>();
            List<user> userTable = userAccess.getTable().ToList<user>();
            foreach (user u in userTable)
            {
                users.Add(new UserDemo
                {
                    id = u.user_id,
                    Name = u.user_fname

                });
            }
            return JsonConvert.SerializeObject(users);
        }