private async Task HandleCreate(Contracts.V1.RegisterUser cmd)
        {
            if (await _store.Exists <Domain.UserProfile.UserProfile, UserId>(new UserId(cmd.Id)))
            {
                throw new InvalidOperationException($"User profile with Id ${cmd.Id} already exists");
            }

            var newUserProfile = new Domain.UserProfile.UserProfile(
                id: new UserId(cmd.Id),
                fullName: FullName.FromString(cmd.FullName),
                displayName: DisplayName.FromString(cmd.DisplayName, _checkText)
                );
            await _store.Save <Domain.UserProfile.UserProfile, UserId>(newUserProfile);
        }
Exemplo n.º 2
0
        private async Task HandleCreate(Contracts.V1.RegisterUser cmd)
        {
            if (await _repository.Exists(new UserId(cmd.UserId)))
            {
                throw new InvalidOperationException($"Entity with id {cmd.UserId} already exists");
            }

            var userProfile = new Domain.UserProfile.UserProfile(
                new UserId(cmd.UserId),
                FullName.FromString(cmd.FullName),
                DisplayName.FromString(cmd.DisplayName, _checkText));

            await _repository.Add(userProfile);

            await _unitOfWork.Commit();
        }
 public Task <IActionResult> Post(Contracts.V1.RegisterUser request)
 {
     return(RequestHandler.HandleRequest(request, _applicationService.Handle, Log));
 }