コード例 #1
0
        public IActionResult GetBlankPreliminaryApplication()
        {
            var applicationDto = new PreliminaryApplicationDto
            {
                Status      = StatusEnum.Preliminary,
                DateOfBirth = DateTime.ParseExact("31/12/2004", "dd/mm/yyyy", CultureInfo.InvariantCulture).ToShortDateString()
            };

            return(Ok(applicationDto));
        }
コード例 #2
0
        public async Task <IActionResult> NewPreliminaryApplication([FromBody] PreliminaryApplicationDto applicationDto)
        {
            var user = await _users.FindByNameAsync(applicationDto.Email, new CancellationToken(false));

            if (user != null)
            {
                return(BadRequest("Already pre-registered"));
            }

            var newUser = new IdentityUser()
            {
                Id                 = Guid.NewGuid().ToString(),
                Email              = applicationDto.Email,
                UserName           = applicationDto.Email,
                NormalizedUserName = applicationDto.Email,
                EmailConfirmed     = false
            };

            newUser.PasswordHash = new PasswordHasher <IdentityUser>().HashPassword(newUser, RandomString(40));

            var newCoreUser = CoreUser.Create(Guid.Parse(newUser.Id));

            newCoreUser.Update(new CoreUserDto()
            {
                Access  = AccessEnum.Standard,
                Picture = @"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAALCElEQVR4nO2de4xdRR3HP3e726W1ltLHFulSxGKpbiltkWKppUskRlQkolQBBRUBFaP4QqIxSJrGBDEoKOIDMUaDmhBFUeujGOqDtljbWkqF9AWtYruVdvug3e7dXf/43d3unvM7e8+599x53J1PMoFM957zPTNzzvzmN7+ZgcCIpmBbgEHGAK3ANOBkYBTQWPq3HqAIHAF2A7tK/1/31GsDKAALgSXAAuB8pOKzsAf4O7AGWAX8BWkoAYe5ALgfeAHoyzl1AA8C7aYeJpCOAvBuYDX5V3pS2gBch3QjAYssAp7EXMVH00Y8/yL4agOMBb4G3JDhN92Igbcb+Zz3AL2lfysgb/MUxFBsBUZnuPYPgZuBwxl+E6iQNmAz5d/Ow8DDwI3AfKApwz2agHlIA3u4dK1y93u2dJ9ADWkHOhm+Ip5AbIKTcrzvGOAq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a+AIVB/z2AeAID9c8/kB3bBhrADGRXjMDIoAuJ7yj22wBlJwkCdUUzsuprwAjU+v9AfTMXTnQBs5B9/QIjh+2EKO/A/wHsftbNgz/GngAAAABJRU5ErkJggg=="
            });

            _readWriteRepository.Create <CoreUser, Guid>(newCoreUser);

            var application = Application.Create(Guid.Parse(newUser.Id), 1);

            var preliminaryDto = new ApplicationDto()
            {
                UserId      = Guid.Parse(newUser.Id),
                Name        = applicationDto.Name,
                Status      = StatusEnum.Preliminary,
                DateOfBirth = applicationDto.DateOfBirth,
                State       = applicationDto.State,
                Country     = applicationDto.Country,
                //Hold over variables
                PhoneNo        = application.PhoneNo,
                RegistrationNo = application.RegistrationNo
            };

            application.Update(preliminaryDto);

            _readWriteRepository.Create <Application, int>(application);

            await _users.CreateAsync(newUser, default(CancellationToken));

            return(Ok());
        }