private User Map(User user, UserDto dto)
        {
            user.Username = dto.Username;
            user.Firstname = dto.Firstname;
            user.Lastname = dto.Lastname;
            user.EmailAddress = dto.EmailAddress;

            user.Roles.Clear();
            user.Groups.Clear();

            // TODO: Implementation Activation workflow
            user.IsActive = true;

            foreach (var role in dto.Roles)
            {
                user.Roles.Add(uow.Roles.GetById(role.Id));
            }

            foreach (var group in dto.Groups)
            {
                user.Groups.Add(uow.Groups.GetById(group.Id));
            }

            return user;
        }
 public void TryToAddUser(UserDto dto)
 {
     var user = Map(new User(), dto);
     user.Password = encryptionService.TransformPassword(dto.Password);
     uow.Users.Add(user);
     uow.SaveChanges();
 }
        public void TryToUpdateUser(UserDto dto)
        {
            var user = uow.Users.GetAll()
                .Include(x => x.Roles)
                .Include(x => x.Groups)
                .Where(x => x.Id == dto.Id)
                .Single();

            Map(user, dto);

            uow.Users.Update(user);
            uow.SaveChanges();
        }