public static User GetUserInfo(this IIdentity identity) { var db = new DotNetTutorials(); using (db) { return db.Users.Find(long.Parse(identity.GetUserId())); } }
protected void ExternalIsUserNameAvaibale(object source, ServerValidateEventArgs args) { var db = new DotNetTutorials(); using (db) { args.IsValid = !db.Users.Select(s => s.UserName.Trim()).Contains(args.Value.Trim()); } }
public static string GetThubmnailUrl(this IIdentity identity) { var db = new DotNetTutorials(); using (db) { var id = long.Parse(identity.GetUserId()); var singleOrDefault = db.Users.SingleOrDefault(u => u.Id == id); return singleOrDefault != null ? "/Images/Users/Thumbnail/" + singleOrDefault.AvatarUrl : null; } }