Пример #1
0
        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();
            }
        }