Пример #1
0
        public double GetTaxRate(string municipalityName, DateTime day)
        {
            var municipality = _municipalityRepo.Get(municipalityName);
            var tax          = municipality?.Taxes?.Where(t => DateUtils.IsDateInclusive(t.From, t.To, day))
                               .OrderBy(t => t.TaxType)
                               .FirstOrDefault() ?? throw new TaxNotAppliedException();

            return(tax.Rate);
        }
Пример #2
0
        public void CanGetTaxRate(List <Tax> taxes, DateTime day, double expectedRate)
        {
            var municipality = "Vilnius";

            _municipalityRepo.Get(municipality).Returns(new Municipality {
                Taxes = taxes
            });

            var rate = _taxService.GetTaxRate(municipality, day);

            rate.ShouldBe(expectedRate);
        }
Пример #3
0
 /// <summary>
 /// The GetMunicipality
 /// </summary>
 /// <param name="id">The id<see cref="int"/></param>
 /// <returns>The <see cref="ServiceResult"/></returns>
 public ServiceResult GetMunicipality(int id)
 {
     return(new ServiceResult(true)
     {
         Data = _repository.Get(x => x.Identifier == id)
     });
 }
Пример #4
0
        public void CanDelete()
        {
            string municipalityToDelete = "Vilnius";

            _municipalityRepo.Get(municipalityToDelete).Returns(new Municipality {
                Name = municipalityToDelete
            });

            var isDeleted = _municipalityService.Delete(municipalityToDelete);

            isDeleted.ShouldBe(true);
        }
        public bool Delete(string manucipalityName)
        {
            var municipality = _municipalityRepo.Get(manucipalityName);

            if (municipality == null)
            {
                return(false);
            }

            _municipalityRepo.Remove(municipality);
            _municipalityRepo.Save();
            return(true);
        }
Пример #6
0
        private void ImportMunicipality(Municipality municipalityToAdd)
        {
            var existingMunicipality = _municipalityRepo.Get(municipalityToAdd.Name);

            if (existingMunicipality == null)
            {
                _municipalityRepo.Add(municipalityToAdd);
                existingMunicipality = new Municipality {
                    Id = municipalityToAdd.Id
                };
            }

            ImportMunicipalityTaxes(existingMunicipality, municipalityToAdd.Taxes);
        }
        public async Task <Municipality> GetMunicipality(string name)
        {
            //TODO: fix naming
            var municipalities = await _municipalityRepository.Get(municipality => municipality.GetName() == name, new CancellationToken());

            var enumerable = municipalities.ToList();

            if (enumerable.Count() == 1)
            {
                return(enumerable.ToList().First());
            }
            else
            {
                throw new Exception("There should not be two municipalities with the same name");
            }
        }