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