Ejemplo n.º 1
0
        public Task <IdentityResult> CreateAsync(T user, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            using (var db = new WeatherDb())
            {
                if (db.Insert(user) > 0)
                {
                    return(Success());
                }

                return(Fail());
            }
        }
Ejemplo n.º 2
0
        public Task AddToRoleAsync(T user, string roleName, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            using (var db = new WeatherDb())
            {
                var roleId = db.UserRole.First(r => r.NormalizedName.Equals(roleName)).Id;

                db.Insert(new UserInRole()
                {
                    UserId = user.Id, RoleId = roleId
                });
            }

            return(Task.FromResult <object>(null));
        }