Exemplo n.º 1
0
        public IActionResult TaxRatesList(int taxId)
        {
            Tax tax = null;

            if (taxId <= 0 || (tax = _taxService.FirstOrDefault(x => x.Id == taxId)) == null)
            {
                return(NotFound());
            }
            var taxRates = _taxRateService.Get(x => x.TaxId == taxId);

            var models = taxRates.Select(x =>
            {
                var model                 = _modelMapper.Map <TaxRateModel>(x);
                model.CountryName         = x.Country.Name;
                model.StateOrProvinceName = x.StateOrProvince?.Name;
                return(model);
            }).ToList();

            return(R.Success.With("taxRates", models)
                   .WithGridResponse(models.Count, 1, models.Count)
                   .With("taxId", taxId)
                   .With("taxName", tax.Name)
                   .WithAvailableCountries()
                   .Result);
        }