public static bool IsActivated(string userId) { if (userId != null || userId != " ") { var ctx = new OruBloggenDbContext(); var userIsActivated = ctx.Users.FirstOrDefault(u => u.UserID == userId).UserActive; return(userIsActivated); } return(true); }
protected override bool AuthorizeCore(HttpContextBase context) { var userId = context.User.Identity.GetUserId(); if (userId != null || userId != " ") { var ctx = new OruBloggenDbContext(); try { var userIsActivated = ctx.Users.FirstOrDefault(u => u.UserID == userId).UserActive; return(userIsActivated); } catch (Exception e) { return(true); } } return(true); }
public static List <SelectListItem> getSearchedUsers(string searchString) { var ctx = new OruBloggenDbContext(); var userList = ctx.Users.Where(u => String.Concat(u.UserFirstname, " ", u.UserLastname) .Contains(searchString) || searchString == null).ToList(); var users = new List <SelectListItem>(); foreach (var item in userList) { users.Add(new SelectListItem { Text = item.UserFirstname + " " + item.UserLastname, Value = item.UserID }); } return(users); }
public static string getCategoryById(int categoryId) { var ctx = new OruBloggenDbContext(); return(ctx.Categories.FirstOrDefault(u => u.CategoryID == categoryId).CategoryName); }
public static bool isAdmin(string userId) { var ctx = new OruBloggenDbContext(); return(ctx.Users.FirstOrDefault(u => u.UserID == userId).UserIsAdmin); }