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();
            }
        }
Esempio n. 2
0
 public void DeleteProfile(Guid id)
 {
     try
     {
         _profilesRepository.DeleteProfile(id);
     }
     catch (SqlException exception)
     {
         var response = new HttpResponseMessage(HttpStatusCode.NotFound)
         {
             Content = new StringContent(exception.Message)
         };
         throw new HttpResponseException(response);
     }
 }
        public async Task DeleteProfile(string profileId)
        {
            await _pairingsRepository.DeletePairings(profileId);

            await _profilesRepository.DeleteProfile(profileId);
        }