public AdminInvite Create() { var link = AdminInvite.CreateEntity(this.ForUser, this.ExpiresAt.AddTicks(-1).AddDays(1), this.WillBeAdmin, this.WillBeEmployee); return(link); }
private async Task TryAddRole(AdminInvite link, User user) { if (link != null) { if (link.WillBeAdmin) { await this.userManager.AddToRoleAsync(user, RoleType.Administrator.ToString()); } if (link.WillBeEmployee) { await this.userManager.AddToRoleAsync(user, RoleType.Employee.ToString()); } link.IsRedeemed = true; RepositoriesFactory.SaveChanges(); } }
public AdminLinkViewModel(AdminInvite invite) { this.ForUser = invite.ForUser; this.ExpiresAt = invite.ExpiresAt; this.ForRoles = new List <RoleType>(); this.Id = invite.Id; if (invite.WillBeAdmin) { this.ForRoles.Add(RoleType.Administrator); } if (invite.WillBeEmployee) { this.ForRoles.Add(RoleType.Employee); } }