public async Task<IActionResult> DeleteUser([FromQuery]string Id) { try { // Delete all of the users listings first _companiesRepository.DeleteMyCompanies(Id); _consultantsRepository.DeleteMyConsultants(Id); _jobsRepository.DeleteMyJobs(Id); _localEventsRepository.DeleteMyEvents(Id); // Delete the profile _profileRepo.DeleteProfile(_profileRepo.GetProfileByUserId(Id)); // Now delete the user AppUser user = await _userManager.FindByIdAsync(Id); var isDeleted = await _userManager.DeleteAsync(user); if(isDeleted.Succeeded) { return Ok(); } else { return NotFound(); } } catch (Exception) { return NotFound(); } }
public IActionResult GetMyProfile() { string userId = IdentityHelper.GetUserId(HttpContext); if (string.IsNullOrEmpty(userId)) { return(NotFound()); } Profile profile = _profileRepository.GetProfileByUserId(userId); return(Ok(profile)); }