Exemplo n.º 1
0
        public async static Task <IdentityResult> AddUserToRole(this ApplicationUserManager manager, ApplicationUser user, string role)
        {
            ArtBrowserDBContext db   = new ArtBrowserDBContext();
            UserType            Role = ((UserType)Enum.Parse(typeof(UserType), role));

            switch (Role)
            {
            case UserType.Artist:
                db.Artists.Add(new Artist()
                {
                    User_ID = user.Id
                });
                break;

            case UserType.Institution:
                db.Institutions.Add(new Institution()
                {
                    User_ID = user.Id
                });
                break;
            }

            db.SaveChanges();
            return(await manager.AddToRoleAsync(user.Id, role));
        }