Exemplo n.º 1
0
 public ActionResult LogOn(Users user)
 {
     var q = from u in DBContext.Users
             join r in DBContext.Roles on u.RoleId equals r.Id
             where u.Number == user.Number && u.Password==user.Password&&r.Name=="讲解员"
             select u.Id;
     int id = q.FirstOrDefault();
     if (id != 0)
     {
         FormsAuthentication.SetAuthCookie(id.ToString(), false);
         return RedirectToAction("PlayList", "pad");
     }
     else
     {
         ViewData["Error"] = "用户名或密码错误,请重新填写!";
         return View();
     }
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(Users users)
 {
     base.AddObject("Users", users);
 }
 /// <summary>
 /// Create a new Users object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="number">Initial value of the Number property.</param>
 /// <param name="roleId">Initial value of the RoleId property.</param>
 public static Users CreateUsers(global::System.Int32 id, global::System.String name, global::System.String password, global::System.String number, global::System.Int32 roleId)
 {
     Users users = new Users();
     users.Id = id;
     users.Name = name;
     users.Password = password;
     users.Number = number;
     users.RoleId = roleId;
     return users;
 }
Exemplo n.º 4
0
 public ActionResult EditUser(Users user)
 {
     var obj = DBContext.Users.FirstOrDefault(e => e.Id == user.Id);
     if (user.Password != null && user.Password.Trim() != string.Empty)
         obj.Password = user.Password;
     obj.Number = user.Number;
     obj.Name = user.Name;
     obj.Tel = user.Tel;
     obj.Email = user.Email;
     obj.Remark = user.Remark;
     if (obj.RoleId != user.RoleId)
     {
         var result = DBContext.UsersRights.Where(e => e.UserId == obj.Id);
         foreach (var v in result)
             DBContext.DeleteObject(v);
         obj.RoleId = user.RoleId;
         AuthorizationToUser(obj.Id, user.RoleId);
     }
     else
     {
         DBContext.SaveChanges();
     }
     return RedirectToAction("IndexUser");
 }
Exemplo n.º 5
0
 public ActionResult AddUser(Users user)
 {
     DBContext.AddToUsers(user);
     DBContext.SaveChanges();
     AuthorizationToUser(user.Id, user.RoleId);
     return RedirectToAction("IndexUser");
 }