public async Task DeleteUser(string id) { var trainer = await _trainerRepository.GetTrainerByUser(id); if (trainer != null) { var trainings = await _trainingRepository.GetTrainerTrainings(trainer.Id); foreach (var training in trainings) { await _trainingRepository.DeleteTraining(training); } var favs = await _favouriteRepository.GetFavouriteTrainers(trainer.Id); foreach (var fav in favs) { await _favouriteRepository.DeleteFavouriteTrainer(fav); } await _trainerRepository.DeleteTrainer(trainer); } var clubs = await _clubRepository.GetUserClubs(id); if (clubs.Count() != 0) { foreach (var club in clubs) { var trainings = await _trainingRepository.GetClubTrainings(club.Id); foreach (var training in trainings) { await _trainingRepository.DeleteTraining(training); } var favs = await _favouriteRepository.GetFavouriteClubs(club.Id); foreach (var fav in favs) { await _favouriteRepository.DeleteFavouriteClub(fav); } await _clubRepository.DeleteClub(club); } } var favClubs = await _favouriteRepository.GetUserFavouriteClubs(id); if (favClubs.Count() != 0) { foreach (var club in favClubs) { await _favouriteRepository.DeleteFavouriteClub(club); } } var favTrainers = await _favouriteRepository.GetUserFavouriteTrainers(id); if (favTrainers.Count() != 0) { foreach (var favTrainer in favTrainers) { await _favouriteRepository.DeleteFavouriteTrainer(favTrainer); } } var clubRates = await _rateRepository.GetUserClubRates(id); if (clubRates.Count() != 0) { foreach (var rate in clubRates) { await _rateRepository.DeleteClubRate(rate); } } var trainerRates = await _rateRepository.GetUserTrainerRates(id); if (trainerRates.Count() != 0) { foreach (var rate in trainerRates) { await _rateRepository.DeleteTrainerRate(rate); } } var bodyMeasurements = await _bodyMeasurementRepository.GetBodyMeasurements(id); if (bodyMeasurements.Count() != 0) { foreach (var measurement in bodyMeasurements) { await _bodyMeasurementRepository.DeleteBodyMeasurement(measurement); } } var reservedTrainings = await _trainingRepository.GetReservedTrainings(id, true); var reservations = await _reservationRepository.GetReservations(id); if (reservations.Count() != 0) { foreach (var reservation in reservations) { await _reservationRepository.DeleteReservation(reservation); } } foreach (var trng in reservedTrainings) { await _trainingService.UpdateSignedUpList(trng); } var userTrainings = await _userTrainingRepository.GetUserTrainings(id); if (userTrainings.Count() != 0) { foreach (var userTraining in userTrainings) { await _userTrainingRepository.DeleteUserTraining(userTraining); } } var chats = await _chatRepository.GetAllChats(id); if (chats.Count() != 0) { foreach (var chat in chats) { await _chatRepository.DeleteChat(chat); } } var user = await _userRepository.GetUser(id); await _userRepository.DeleteUser(user); }
public async Task DeleteBodyMeasurement(int id) { var measurement = await _bodyMeasurementRepository.GetBodyMeasurement(id); await _bodyMeasurementRepository.DeleteBodyMeasurement(measurement); }