예제 #1
0
        public AdminInvite Create()
        {
            var link = AdminInvite.CreateEntity(this.ForUser,
                                                this.ExpiresAt.AddTicks(-1).AddDays(1), this.WillBeAdmin, this.WillBeEmployee);

            return(link);
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        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);
            }
        }