Beispiel #1
0
        public async Task <bool> RegisterTeamUser(RegisterViewModel model, string role)
        {
            ApplicationUser teamUser;

            if (role == AgentRole)
            {
                teamUser = new AgentUsers
                {
                    UserName  = model.UserName.Trim(' '),
                    Email     = model.Email,
                    CreatedOn = DateTime.Now
                };
            }
            else
            {
                teamUser = new ApplicationUser
                {
                    UserName  = model.UserName.Trim(' '),
                    Email     = model.Email,
                    CreatedOn = DateTime.Now
                };
            }
            var result = await userManager.CreateAsync(teamUser, model.Password);

            if (result.Succeeded)
            {
                var currentUser = await userManager.FindByNameAsync(teamUser.UserName);

                await userManager.AddToRolesAsync(currentUser.Id, TeamUserRole, role);

                return(true);
            }

            return(false);
        }
Beispiel #2
0
 public AgentUsersInfoDTO(AgentUsers agent)
 {
     AgentId  = agent.Id;
     FullName = agent.FirstName + " " + agent.LastName;
     AdditionalDescription = agent.AdditionalDescription;
     PhoneNumber           = agent.PhoneNumber;
     Email     = agent.Email;
     ImagePath = agent.Images.Select(i => i.ImagePath).FirstOrDefault();
 }