/// <summary> /// Get the first user id with the given role. /// </summary> public static string GetUserRoleId(CmagruDBContext dBContext, string roleName) { var role = dBContext.Roles.First(x => x.NormalizedName == roleName.ToUpper()); var userRole = dBContext.UserRoles.FirstOrDefault(x => x.RoleId == role.Id); return(userRole.UserId); }
public static string GetUserRole(CmagruDBContext dBContext, ApplicationUser user) { var role = dBContext.UserRoles.FirstOrDefault(x => x.UserId == user.Id); if (role == null) { return(null); } return(dBContext.Roles.First(x => x.Id == role.RoleId).Name); }
public ImgControl( ILogger logger, CmagruDBContext context, UserManager <ApplicationUser> userManager, IEmailService emailService) { _logger = logger; _context = context; _userManager = userManager; _emailService = emailService; }
public PhotoRoomController( ILogger <AccountController> logger, CmagruDBContext context, UserManager <ApplicationUser> userManager, IEmailService emailService) { _logger = logger; _context = context; _userManager = userManager; _imgCtrl = new ImgControl(_logger, _context, _userManager, emailService); }
public PhotoWallController( ILogger <AccountController> logger, CmagruDBContext context, UserManager <ApplicationUser> userManager, IEmailService emailService, IAuthorizationService authorizationService) { _logger = logger; _context = context; _userManager = userManager; _authorizationService = authorizationService; _imgCtrl = new ImgControl(logger, context, userManager, emailService); }
public AccountController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, CmagruDBContext context, ILogger <AccountController> logger, IMapper mapper, IEmailService emailService) { System.Security.Claims.ClaimsPrincipal a = User; _logger = logger; _mapper = mapper; _userManager = userManager; _signInManager = signInManager; _emailService = emailService; _context = context; }
/// <summary> /// Send email notification to target, if email is /// confirmed and target allows notifications. /// </summary> public static void SendEmailNotif( CmagruDBContext context, IEmailService emailService, string targetUserId, string subject, string content) { var targetUser = context.Users.Find(targetUserId); if (targetUser == null) { return; } if (!targetUser.EmailConfirmed) { return; } var settings = context.GetUserSettings .FirstOrDefault(x => x.UserId == targetUser.Id); if (settings == null) { return; } if (!settings.SendEmailNotifs) { return; } emailService.Send(new EmailMessage { ToAddress = targetUser.Email, Subject = subject, Content = content }); }