Mubarak Suleiman

Mubarak Suleiman

  • NA
  • 10
  • 1.1k

where and what to add picture property

Mar 27 2018 3:12 AM
Hi,
 
i am working on project and i want to picture property on identityModel.cs, i don't know where to add and what to add? i am very new to EF. i was just following a video to practise and i don't want to skip any step.
  1. using System;  
  2. using System.Security.Claims;  
  3. using System.Threading.Tasks;  
  4. using System.Web;  
  5. using Microsoft.AspNet.Identity;  
  6. using Microsoft.AspNet.Identity.EntityFramework;  
  7. using Microsoft.AspNet.Identity.Owin;  
  8. using Microsoft.Owin.Security;  
  9. using SocialSiteManager.Models;  
  10. namespace SocialSiteManager.Models  
  11. {  
  12. // You can add User data for the user by adding more properties to your User class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.  
  13. public class ApplicationUser : IdentityUser  
  14. {  
  15. public string Picture { getset; }  
  16. }  
  17. public ClaimsIdentity GenerateUserIdentity(ApplicationUserManager manager)  
  18. {  
  19. // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType  
  20. var userIdentity = manager.CreateIdentity(this, DefaultAuthenticationTypes.ApplicationCookie);  
  21. // Add custom user claims here  
  22. return userIdentity;  
  23. }  
  24. public Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager)  
  25. {  
  26. return Task.FromResult(GenerateUserIdentity(manager));  
  27. }  
  28. }  
  29. public class ApplicationDbContext : IdentityDbContext<ApplicationUser>  
  30. {  
  31. public ApplicationDbContext()  
  32. base("DefaultConnection", throwIfV1Schema: false)  
  33. {  
  34. }  
  35. public static ApplicationDbContext Create()  
  36. {  
  37. return new ApplicationDbContext();  
  38. }  
  39. }  
  40. }  
  41. #region Helpers  
  42. namespace SocialSiteManager  
  43. {  
  44. public static class IdentityHelper  
  45. {  
  46. // Used for XSRF when linking external logins  
  47. public const string XsrfKey = "XsrfId";  
  48. public const string ProviderNameKey = "providerName";  
  49. public static string GetProviderNameFromRequest(HttpRequest request)  
  50. {  
  51. return request.QueryString[ProviderNameKey];  
  52. }  
  53. public const string CodeKey = "code";  
  54. public static string GetCodeFromRequest(HttpRequest request)  
  55. {  
  56. return request.QueryString[CodeKey];  
  57. }  
  58. public const string UserIdKey = "userId";  
  59. public static string GetUserIdFromRequest(HttpRequest request)  
  60. {  
  61. return HttpUtility.UrlDecode(request.QueryString[UserIdKey]);  
  62. }  
  63. public static string GetResetPasswordRedirectUrl(string code, HttpRequest request)  
  64. {  
  65. var absoluteUri = "/Account/ResetPassword?" + CodeKey + "=" + HttpUtility.UrlEncode(code);  
  66. return new Uri(request.Url, absoluteUri).AbsoluteUri.ToString();  
  67. }  
  68. public static string GetUserConfirmationRedirectUrl(string code, string userId, HttpRequest request)  
  69. {  
  70. var absoluteUri = "/Account/Confirm?" + CodeKey + "=" + HttpUtility.UrlEncode(code) + "&" + UserIdKey + "=" + HttpUtility.UrlEncode(userId);  
  71. return new Uri(request.Url, absoluteUri).AbsoluteUri.ToString();  
  72. }  
  73. private static bool IsLocalUrl(string url)  
  74. {  
  75. return !string.IsNullOrEmpty(url) && ((url[0] == '/' && (url.Length == 1 || (url[1] != '/' && url[1] != '\\'))) || (url.Length > 1 && url[0] == '~' && url[1] == '/'));  
  76. }  
  77. public static void RedirectToReturnUrl(string returnUrl, HttpResponse response)  
  78. {  
  79. if (!String.IsNullOrEmpty(returnUrl) && IsLocalUrl(returnUrl))  
  80. {  
  81. response.Redirect(returnUrl);  
  82. }  
  83. else  
  84. {  
  85. response.Redirect("~/");  
  86. }  
  87. }  
  88. }  
  89. }  
  90. #endregion