public static string GetProfilePicturePath(this IIdentity identity) { EmuzerDbContext db = new EmuzerDbContext(); var userId = identity.GetUserId(); var user = db.Users.FirstOrDefault(u => u.Id == userId); var picture = user.ProfilePicture; return(picture.FilePath); }
public ActionResult GetFacebookPicture() { var db = new EmuzerDbContext(); var userId = User.Identity.GetUserId(); var user = db.Users.FirstOrDefault(u => u.Id == userId); user.ProfilePicture.FilePath = GetFacebookInformation.GetPictureUrl( user?.Logins?.FirstOrDefault(l => l.LoginProvider == "Facebook")?.ProviderKey); user.ProfilePicture.ProviderType = PictureProviderType.Facebook; if (!string.IsNullOrEmpty(user.ProfilePicture.FilePath)) { db.SaveChanges(); } return(RedirectToAction("Index")); }
protected Repository() { context = new EmuzerDbContext(); }