Example #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>();
        }
Example #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;
 }
Example #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());
        }
Example #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; }
            }
        }
Example #5
0
 private LogModel()
 {
     dbEntities = new CMSEntities();
 }