Beispiel #1
0
        private List<UserViewModel> GetAllUser()
        {
            List<Users> users = new CMSEntities().Users.ToList();
            var q = from u in users
                    select new UserViewModel { Id = u.Id, Name = u.Name };

            return q.ToList<UserViewModel>();
        }
Beispiel #2
0
 public bool CreateUser(Users model)
 {
     using (CMSEntities db = new CMSEntities())
     {
         if (model != null)
         {
             Users aa = new Users();
             aa.Password = model.Password;
             aa.Name = model.Name;
             db.AddToUsers(aa);
             db.SaveChanges();
             return true;
         }
     }
     return false;
 }
Beispiel #3
0
        public ActionResult AddUser(string name, string password)
        {
            if (string.IsNullOrEmpty(name))
            {
                return null;
            }

            Users user = new Users()
            {
                Name = name,
                Password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5")
            };
            var db = new CMSEntities();
            db.Users.AddObject(user);
            db.SaveChanges();

            return PartialView("_UserList", this.GetAllUser());
        }
Beispiel #4
0
        public bool ValidateUser(Users model)
        {
            using (CMSEntities db = new CMSEntities())
            {
                Users result = db.Users.FirstOrDefault(m => m.Name == model.Name);

                if (result != null)
                {
                    string newPsw = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(model.Password, "MD5");
                    if (result.Password == newPsw)
                    {
                        return true;
                    }
                    else { return false; }
                }
                else { return false; }
            }
        }
Beispiel #5
0
 private LogModel()
 {
     dbEntities = new CMSEntities();
 }