public void DeleteIndicator(User user, Indicator indicator) { UserIndicator toDelete = userIndicatorRepository.Get(user, indicator); if (!userIndicatorRepository.Has(toDelete)) { throw new DoesNotExistsException("Indicador no existe"); } userIndicatorRepository.Delete(toDelete); userIndicatorRepository.Save(); }
public void DeleteIndicator(int id) { Indicator indicator = new Indicator(); indicator.ID = id; if (!repository.Has(indicator)) { throw new DoesNotExistsException("Indicador no existe"); } UserIndicatorRepository userIndicatorRepository = new UserIndicatorRepository(); indicator = repository.GetByID(id); List <UserIndicator> userIndicators = userIndicatorRepository.GetAll().ToList(); foreach (UserIndicator userIndicator in userIndicators) { if (userIndicator.indicator == id) { userIndicatorRepository.Delete(userIndicator); userIndicatorRepository.Save(); } } NodeRepository nr = new NodeRepository(); if (!(repository.GetByID(id).Green == null)) { nr.Delete(repository.GetByID(id).Green); } if (!(repository.GetByID(id).Red == null)) { nr.Delete(repository.GetByID(id).Red); } if (!(repository.GetByID(id).Yellow == null)) { nr.Delete(repository.GetByID(id).Yellow); } nr.Save(); repository.Delete(indicator); repository.Save(); }