Ejemplo n.º 1
0
        public async Task <Result> CreateUserAsync(INventoryUser user, string password)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            var newUser = new NventoryUser()
            {
                Id          = user.Id,
                UserName    = user.UserName,
                Email       = user.Email,
                Name        = user.Name,
                Surname     = user.Surname,
                Patronymic  = user.Patronymic,
                StaffNumber = user.StaffNumber
            };
            var result = await _userManager.CreateAsync(newUser, password).ConfigureAwait(false);

            return(new Result(result.Succeeded, result.Errors.Select(e => e.Description).ToArray()));
        }
Ejemplo n.º 2
0
 private async Task <IList <INventoryRole> > GetUserRoles(NventoryUser user)
 {
     return((await _userManager.GetRolesAsync(user))
            .Select(rolename => _roleManager.Roles.First(r => r.Name == rolename))
            .ToList <INventoryRole>());
 }