コード例 #1
0
        public async Task <IActionResult> Post([FromBody] RegistrationDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var userIdentity = ApplicationUserMapper.RegistrationDtoToApplicationUser(dto);

            var result = await _userService.CreateUserAsync(userIdentity, dto.Password);

            if (!result.Succeeded)
            {
                return(new BadRequestObjectResult(Errors.AddErrorsToModelState(result, ModelState)));
            }

            var createCommand =
                new CreateBusinessUserCommand(Guid.NewGuid(),
                                              new IdentityId(userIdentity.Id),
                                              dto.Location,
                                              null,
                                              null,
                                              new Email(userIdentity.Email),
                                              userIdentity.FirstName,
                                              null,
                                              userIdentity.LastName);

            await _commandBus.Send(createCommand);

            return(new OkObjectResult(new ResponseObject {
                Message = "Account Created"
            }));
        }
コード例 #2
0
        public void Add(UserCreatedEvent userCreatedEvent)
        {
            try
            {
                var userStream = ApplicationUserMapper.UserCreatedEventToStream(userCreatedEvent);

                var resp = _elasticClient.Index(userStream, i => i
                                                .Refresh(Refresh.True)
                                                );
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
コード例 #3
0
        public void ShouldMapCorrectlyOnCreateSomeDataCommandToPersistanceModel()
        {
            var dto = new RegistrationDto
            {
                Email     = "*****@*****.**",
                FirstName = "SomeFirstName",
                LastName  = "SomeLastname",
                Location  = "SomeLocation",
                Password  = "******"
            };
            var mapped = ApplicationUserMapper.RegistrationDtoToApplicationUser(dto);

            Assert.Equal(dto.FirstName, mapped.FirstName);
            Assert.Equal(dto.Email, mapped.Email);
            Assert.Equal(dto.LastName, mapped.LastName);
            Assert.Equal(mapped.UserName, dto.Email);
        }
コード例 #4
0
 public AccountRepo(IdentityContext context, ApplicationUserMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }