本文整理汇总了C#中ApplicationUserManager.FindById方法的典型用法代码示例。如果您正苦于以下问题:C# ApplicationUserManager.FindById方法的具体用法?C# ApplicationUserManager.FindById怎么用?C# ApplicationUserManager.FindById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApplicationUserManager
的用法示例。
在下文中一共展示了ApplicationUserManager.FindById方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadAccountDetails
private void LoadAccountDetails(ApplicationUserManager manager)
{
var user = manager.FindById(CurrentUserId);
FirstName.Text = user.FirstName;
LastName.Text = user.LastName;
UserName.Text = user.UserName;
Email.Text = user.Email;
}
示例2: Index
public ActionResult Index()
{
MyAccountViewModel model;
using (var manager = new ApplicationUserManager())
{
ApplicationUser user = manager.FindById(CurrentUserId);
model = new MyAccountViewModel(user.UserName, user.Email ?? string.Empty);
}
return View(model);
}
示例3: ClearUserRoles
public void ClearUserRoles(ApplicationUserManager userManager, string userId)
{
var user = userManager.FindById(userId);
var currentRoles = new List<IdentityUserRole>();
currentRoles.AddRange(user.UserRoles);
foreach (var role in currentRoles)
{
userManager.RemoveFromRole(userId, role.RoleId);
}
}
示例4: BuildAsync
public static async Task<IEnumerable<LoginDetailViewMode>> BuildAsync()
{
if (HttpContext.Current == null)
throw new InvalidOperationException("Invalid HttpContext");
if (!HttpContext.Current.User.Identity.IsAuthenticated)
return null;
List<LoginDetailViewMode> result = new List<LoginDetailViewMode>();
if (HttpContext.Current == null)
throw new InvalidOperationException("Invalid HttpContext");
if (!HttpContext.Current.User.Identity.IsAuthenticated)
return null;
var userId = HttpContext.Current.User.Identity.GetUserId();
var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
IList<UserLoginInfo> logins = null;
// Creating our own ApplicationUserManager instance.
// We shouldn't persisting changes back to the database and changes made in another
// instance are not reflected here.
using (var userManager = new ApplicationUserManager(new UserStore<ApplicationUser>(new ApplicationDbContext())))
{
logins = await userManager.GetLoginsAsync(userId);
foreach (var loginInfo in logins)
{
// Add helpers here
var item = FacebookHelper.GetLoginDetails(loginInfo.ProviderKey);
if (item != null && !result.Contains(item))
result.Add(item);
}
// Is a
if (result.Count == 0)
{
var user = userManager.FindById(userId);
result.Add(new LoginDetailViewMode
{
FirstName = user.FirstName,
Name = HttpContext.Current.User.Identity.Name
});
}
}
return result;
}
示例5: ClearUserRoles
public void ClearUserRoles(string userId)
{
var um = new ApplicationUserManager(
new UserStore<ApplicationUser>(context));
var user = um.FindById(userId);
var currentRoles = new List<IdentityUserRole>();
currentRoles.AddRange(user.Roles);
foreach (var role in currentRoles)
{
um.RemoveFromRole(userId, role.RoleId);
}
}
示例6: Compose_Private_Booking_Email
private static MailMessage Compose_Private_Booking_Email(ApplicationUser booker, List<Meeting> bookedMeetings,
ApplicationUserManager userManager, bool toStudent)
{
var checkedMeeting = bookedMeetings.First();
var instructor = userManager.FindById(checkedMeeting.InstructorId);
var subjectLine = "Meeting: " + checkedMeeting.Title + " - " + StarterTimeText(checkedMeeting);
var bodyText = "";
if (toStudent)
{
bodyText = GenerateBodyText(checkedMeeting, "", booker, instructor);
}
var confirmationEmailMessage = BuildEmailMessage(booker, subjectLine, bodyText);
return confirmationEmailMessage;
}
示例7: GenerateConfirmationEmailMessage
private static MailMessage GenerateConfirmationEmailMessage(Meeting bookedMeeting, IEmailService emailService,
ApplicationUserManager userManager)
{
var instructor = userManager.FindById(bookedMeeting.InstructorId);
var student = userManager.FindById(bookedMeeting.StudentId);
var subjectLine = "Meeting: " + bookedMeeting.Title + " - " + StarterTimeText(bookedMeeting);
var bodyText = GenerateBodyText(bookedMeeting, "", student, instructor);
var confirmationEmailMessage = BuildEmailMessage(student, subjectLine, bodyText);
return confirmationEmailMessage;
}
示例8: Send_Private_Booking_Invitation
public static void Send_Private_Booking_Invitation(Meeting meetingBooked, IEmailService emailService,
ApplicationUserManager userManager)
{
var instructor = userManager.FindById(meetingBooked.InstructorId);
var student = userManager.FindById(meetingBooked.StudentId);
var subjectLine = "Meeting: " + meetingBooked.Title + " - " + StarterTimeText(meetingBooked);
var bodyText = GenerateInvitationText(meetingBooked, "", student, instructor);
var confirmationEmailMessage = BuildEmailMessage(student, subjectLine, bodyText);
try
{
emailService.SendAsync(confirmationEmailMessage);
Log4NetHelper.Log("Send Message To Student: " + confirmationEmailMessage.To, LogLevel.INFO,
"ProcessPrivateMeetingNotifications", meetingBooked.Id,
instructor.Email, null);
}
catch (Exception ex)
{
Log4NetHelper.Log("Send Student Message Failed - ", LogLevel.ERROR, "Meetings", meetingBooked.Id,
instructor.Email, ex);
}
}
示例9: ProcessPrivateMeetingNotifications
public static void ProcessPrivateMeetingNotifications(ApplicationUser currentUser, List<Meeting> meetingsBooked,
IEmailService emailService,
ApplicationUserManager userManager, ApplicationRoleManager roleManager)
{
var studentConfirmationEmailMessage = Compose_Private_Booking_Email(currentUser, meetingsBooked, userManager,
true);
try
{
emailService.SendAsync(studentConfirmationEmailMessage);
Log4NetHelper.Log("Send Message To Student: " + studentConfirmationEmailMessage.To, LogLevel.INFO,
"ProcessPrivateMeetingNotifications", meetingsBooked.First().Id,
"Tester", null);
}
catch (Exception ex)
{
Log4NetHelper.Log("Send Student Message Failed - ", LogLevel.ERROR, "Meetings",
meetingsBooked.First().Id,
"Tester", ex);
}
var instructorId = meetingsBooked.FirstOrDefault()?.InstructorId;
var instructor = userManager.FindById(instructorId);
//Roger todo only first instructor will get notification message;
var instructorConfirmationEmailMessage = Compose_Private_Booking_Email(instructor, meetingsBooked,
userManager, false);
if (instructorConfirmationEmailMessage != null)
{
try
{
emailService.SendAsync(instructorConfirmationEmailMessage);
Log4NetHelper.Log("Send Message To Instructor: " + instructorConfirmationEmailMessage.To,
LogLevel.INFO, "ProcessPrivateMeetingNotifications", meetingsBooked.First().Id,
"Tester", null);
}
catch (Exception ex)
{
Log4NetHelper.Log("Send Student Message Failed - ", LogLevel.INFO, "Meetings",
meetingsBooked.First().Id,
"Tester", ex);
}
}
}