public IList <TaxList> GetTaxes(string userId) { var taxes = _taxRepository.GetList2(x => x.Country, x => x.Currency, x => x.FrequenceOption, x => x.TaxType) .Where(x => x.UserId == userId).ToList(); var mappedTaxes = new List <TaxList>(); foreach (var tax in taxes) { var mappedTax = Mapper.Map <TaxList>(tax); switch ((DataAccessLayer.Enumerations.FrequenceOption)tax.FrequenceOptionId) { case DataAccessLayer.Enumerations.FrequenceOption.Once: mappedTax.FrequenceDescription = "Once"; break; case DataAccessLayer.Enumerations.FrequenceOption.EveryXMonths: mappedTax.FrequenceDescription = $"Every {tax.Frequence} months"; break; } var hasSalary = _salaryRepository.GetList().Any(x => x.TaxId == tax.Id); mappedTax.CanBeDeleted = !hasSalary; mappedTaxes.Add(mappedTax); } return(mappedTaxes.ToList()); }
public IList <CountryList> GetCountries() { var countries = _countryRepository.GetList().ToList(); var mappedCountries = countries.Select(Mapper.Map <CountryList>).ToList(); mappedCountries.ForEach(country => { var hasBank = _bankRepository.GetList().Any(x => x.CountryId == country.Id); var hasSalary = _salaryRepository.GetList().Any(x => x.CountryId == country.Id); var hasPension = _pensionRepository.GetList().Any(x => x.CountryId == country.Id); var hasTax = _taxRepository.GetList().Any(x => x.CountryId == country.Id); country.CanBeDeleted = !hasBank && !hasSalary && !hasPension && !hasTax; }); return(mappedCountries); }
public IList <CurrencyList> GetCurrencies() { var currencies = _currencyRepository.GetList().ToList(); var mappedCurrencies = currencies.Select(Mapper.Map <CurrencyList>).ToList(); mappedCurrencies.ForEach(currency => { var hasAccount = _bankAccountRepository.GetList().Any(x => x.CurrencyId == currency.Id); var hasSalary = _salaryRepository.GetList().Any(x => x.CurrencyId == currency.Id); var hasPension = _pensionRepository.GetList().Any(x => x.CurrencyId == currency.Id); var hasTax = _taxRepository.GetList().Any(x => x.CurrencyId == currency.Id); currency.CanBeDeleted = !hasAccount && !hasSalary && !hasPension && !hasTax; }); return(mappedCurrencies); }