public async Task <IActionResult> CreateProfileAsync([FromBody] ProfileRequestDto profileDto) { try { var actualUserId = _firebaseTokenService.GetTokenData(HttpContext).UserId; if (profileDto.UserId != actualUserId) { return(Unauthorized()); } var oldProfile = await _profileService.GetProfile(profileDto.UserId); if (oldProfile != null) { return(Conflict()); } var profileId = await _profileService.CreateProfile(profileDto); // profileDto does not contain the profile id var profile = await _profileService.GetProfile(profileDto.UserId); return(CreatedAtRoute("GetProfile", profile)); } catch (Exception ex) { _logger.LogError(ex.Message, ex); return(StatusCode(StatusCodes.Status500InternalServerError, ex)); } }
public async Task <ProfileDto> CreateProfile(ProfileRequestDto createProfile) { var checkForEmployee = _stationeryContext.Users.Where(e => e.CorporateEmail == createProfile.CorporateEmail).FirstOrDefault(); if (checkForEmployee != null) { throw new AppException("User exists"); } var newUser = new User { //UserId = Guid.NewGuid(), FirstName = createProfile.FirstName, LastName = createProfile.LastName, CorporateEmail = createProfile.CorporateEmail, //JobPosition = createProfile.JobPosition, IsActive = 1, UnitId = _stationeryContext.Units.Where(u => u.UnitName == createProfile.UnitName).Select(i => i.UnitId).FirstOrDefault() }; await _stationeryContext.AddAsync(newUser); await _stationeryContext.SaveChangesAsync(); return(GetProfile(newUser.UserId)); }
public async Task <IActionResult> GetProfile([FromQuery] ProfileRequestDto request) { var path = string.Format("v1/profile?{0}", request.GetQueryString()); var result = await Helpers.ACBOpenApi.Call <dynamic>(Request.HttpContext, MethodBase.GET, path, null, null); if (result.Data != null) { return(Ok(result)); } else { return(BadRequest(result)); } }
public async Task <int> CreateProfile(ProfileRequestDto profileInfo) { var profile = new Profile { UserId = profileInfo.UserId, FirstName = profileInfo.FirstName, LastName = profileInfo.LastName, Email = profileInfo.Email, }; _context.Profiles.Add(profile); await _context.SaveChangesAsync(); return(profile.Id); }
public async Task <IActionResult> Edit(ProfileRequestDto profile) { return(HandleResult(await Mediator.Send(new EditProfileCommand { DisplayName = profile.DisplayName, Bio = profile.Bio }))); }
public async Task <ActionResult> Put( ProfileRequestDto profileRequestDto, [FromServices] ICommandDispatcher commandDispatcher) { return(Ok(await commandDispatcher.Dispatch(new UpdateMyProfileCommand(profileRequestDto)).ConfigureAwait(false))); }
public UpdateMyProfileCommand(ProfileRequestDto myProfileRequestDto) { MyProfileRequestDto = myProfileRequestDto; }