示例#1
0
        public async Task <UserViewModel> Handle(CreateUserCommand request, CancellationToken cancellationToken)
        {
            var user = await service.LoadUserFromAuthServerAsync(request.Token);

            if (user.UserType == UserType.Guest)
            {
                user = new Guest(user)
                {
                    RegisterDate = dateTime.Now
                }
            }
            ;
            else
            {
                user = new Manager(user);
            }

            context.Users.Add(user);

            await context.SaveChangesAsync(cancellationToken);

            return(mapper.Map <UserViewModel>(user));
        }