public override string[] GetAllRoles() { using (ShopTreeEntities db = new ShopTreeEntities()) { return(db.Levels.Select(lv => lv.Name).ToArray()); } }
public override bool IsUserInRole(string username, string roleName) { using (ShopTreeEntities db = new ShopTreeEntities()) { var user = db.Employees.Where(u => u.Id.ToString().Equals(username)).SingleOrDefault(); return(user.Level.Name.Equals(roleName)); } }
public ActionResult Index() { ViewBag.Title = "Trang chủ"; using (var db = new ShopTreeEntities()) { ViewBag.Name = db.Employees.Where(emp => emp.UserName.Equals(User.Identity.Name)).Select(emp => emp.FullName).SingleOrDefault(); return(View()); } }
public override string[] GetRolesForUser(string username) { using (ShopTreeEntities db = new ShopTreeEntities()) { var user = db.Employees.Where(u => u.UserName.Equals(username)).SingleOrDefault(); if (user != null) { return(new string[] { user.Level.Name }); } else { return(new string[] { }); } } }