public async Task <ActionResult <GetProfileDto> > CreateProfile(AddProfileDto addProfileDto)
        {
            GetProfileDto getProfileDto = null;

            try
            {
                getProfileDto = await _profileService.AddProfileAsync(addProfileDto);
            }
            catch
            {
                return(BadRequest());
            }

            return(CreatedAtRoute(nameof(GetProfileById), new { id = getProfileDto.Id }, getProfileDto));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreateProfile([FromBody] SaveProfileResource profileResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var profile = mapper.Map <SaveProfileResource, Profile>(profileResource);

            profile.CreatedAt = DateTime.Now;
            profile.CreatedBy = profile.UserId.ToString();


            await service.AddProfileAsync(profile);

            await uow.CompleteAsync();

            profile = await service.GetProfile(profile.Id);

            return(Ok(mapper.Map <Profile, ProfileResource>(profile)));
        }
Ejemplo n.º 3
0
        protected async Task <Data.Account> Register(string accountName, string name, AccountTokenType type, bool id_affiliate, string globalId = "")
        {
            if (!accountName.HasValue())
            {
                throw new AccountTokenInvalidException();
            }

            if (!IsTokenUniqueAsync(accountName).Result)
            {
                throw new AccountNotUniqueException();
            }

            Data.Account account = new Data.Account {
                GlobalId          = (globalId.HasValue()) ? globalId : Guid.NewGuid().ToString(),
                WhenCreated       = DateTime.UtcNow,
                WhenAuthenticated = DateTime.UtcNow
            };

            if (!await HasAccounts())
            {
                account.Role = AccountRole.Administrator;
            }

            await _store.Add(account);

            account.Tokens.Add(new Data.AccountToken {
                Hash        = accountName.ToNormalizedSha256(),
                WhenCreated = DateTime.UtcNow,
                Type        = type
            });
            await _store.Update(account);

            if (_options.Registration.StoreName)
            {
                await SetAccountNames(account, name, id_affiliate);
            }

            await _profileService.AddProfileAsync(account.GlobalId, name);

            return(account);
        }
 public async Task <ActionResult <Profile> > CreateProfile(Profile profile) => await _profileService.AddProfileAsync(profile);