Exemplo n.º 1
0
        public async Task <string> ConfirmEmail(string email, string token)
        {
            var user = this.db.Users.Where(p => p.Email == email).FirstOrDefault();

            if (user != null)
            {
                user.ConfirmEmail = true;
                await db.SaveChangesAsync();

                return("succses");
            }
            return("user is null");
        }
Exemplo n.º 2
0
        public async Task <bool> AddTorole(User user, string roleName)
        {
            if (user == null || String.IsNullOrEmpty(roleName))
            {
                return(false);
            }

            var users = await this.dbContext.Users.FindAsync(user.Id);

            var roles = this.dbContext.Roles.Where(r => r.Name == roleName).FirstOrDefault();

            if (user == null || roles == null)
            {
                return(false);
            }
            //var colectionRoles = new List<UserRolse>() { new UserRolse() { UserId = users.Id,RoleId = roles.Id} };
            var useRoles = new UserRolse()
            {
                UserId = users.Id, RoleId = roles.Id
            };

            //if (colectionRoles !=null)
            //{
            //	users.Rolses = colectionRoles;
            //	roles.Users = colectionRoles;
            //	await dbContext.SaveChangesAsync();
            //
            //	return true;
            //}
            if (useRoles != null)
            {
                await dbContext.AddAsync(useRoles);

                await dbContext.SaveChangesAsync();

                return(true);
            }

            return(false);
        }