public async Task <MunicipalityTaxScheduleDto> UpdateExistingMunicipalityTax(int id, MunicipalityTaxScheduleDto municipalityTaxScheduleDto)
        {
            bool isValid = MunicipalityTaxScheduleValidator.IsValid(municipalityTaxScheduleDto);

            if (!isValid)
            {
                throw new ValidationException();
            }

            MunicipalityTaxSchedules taxSchedule = await _municipalityTaxScheduleRepository.GetById(id);

            if (taxSchedule == null)
            {
                throw new NotFoundException("MunicipalityTaxSchedules", id);
            }

            taxSchedule.ModifiedOn       = DateTime.Now;
            taxSchedule.MunicipalityName = municipalityTaxScheduleDto.MunicipalityName;
            taxSchedule.FromDate         = municipalityTaxScheduleDto.FromDate;
            taxSchedule.Todate           = municipalityTaxScheduleDto.Todate;
            taxSchedule.TaxAmount        = municipalityTaxScheduleDto.TaxAmount;

            await _municipalityTaxScheduleRepository.UpdateTaxSchedule(taxSchedule);

            return(MunicipalityTaxScheduleMapper.ToDto(taxSchedule));
        }
示例#2
0
        public async Task <MunicipalityTaxSchedules> AddTaxSchedule(MunicipalityTaxSchedules municipalityTaxSchedule)
        {
            _mtmContext.MunicipalityTaxSchedules.Add(municipalityTaxSchedule);
            await _mtmContext.SaveChangesAsync();

            return(await _mtmContext.MunicipalityTaxSchedules.FindAsync(municipalityTaxSchedule.Id));
        }
示例#3
0
 public static MunicipalityTaxScheduleDto ToDto(MunicipalityTaxSchedules municipalityTaxSchedule)
 {
     return(new MunicipalityTaxScheduleDto()
     {
         Id = municipalityTaxSchedule.Id,
         MunicipalityName = municipalityTaxSchedule.MunicipalityName,
         TaxSheduleTypeId = municipalityTaxSchedule.TaxSheduleTypeId,
         TaxAmount = municipalityTaxSchedule.TaxAmount,
         FromDate = municipalityTaxSchedule.FromDate,
         Todate = municipalityTaxSchedule.Todate
     });
 }
        public async Task <MunicipalityTaxScheduleDto> AddNewMunicipalityTax(MunicipalityTaxScheduleDto municipalityTaxScheduleDto)
        {
            bool isValid = MunicipalityTaxScheduleValidator.IsValid(municipalityTaxScheduleDto);

            if (!isValid)
            {
                throw new ValidationException();
            }

            MunicipalityTaxSchedules taxSchedule = MunicipalityTaxScheduleMapper.ToEntity(municipalityTaxScheduleDto);

            taxSchedule.CreatedOn = DateTime.Now;

            await _municipalityTaxScheduleRepository.AddTaxSchedule(taxSchedule);

            return(MunicipalityTaxScheduleMapper.ToDto(taxSchedule));
        }
        public async Task <MunicipalityTaxScheduleDto> SearchMunicipalityTax(string municipalityName, DateTime date)
        {
            MunicipalityTaxSchedules taxSchedule = await _municipalityTaxScheduleRepository.GetByDay(municipalityName, date);

            if (taxSchedule == null)
            {
                taxSchedule = await _municipalityTaxScheduleRepository.GetByWeek(municipalityName, date);
            }
            if (taxSchedule == null)
            {
                taxSchedule = await _municipalityTaxScheduleRepository.GetByMonth(municipalityName, date);
            }
            if (taxSchedule == null)
            {
                taxSchedule = await _municipalityTaxScheduleRepository.GetByYear(municipalityName, date);
            }
            if (taxSchedule == null)
            {
                return(null);
            }

            return(MunicipalityTaxScheduleMapper.ToDto(taxSchedule));
        }
示例#6
0
        public async Task <MunicipalityTaxSchedules> UpdateTaxSchedule(MunicipalityTaxSchedules municipalityTaxSchedule)
        {
            await _mtmContext.SaveChangesAsync();

            return(municipalityTaxSchedule);
        }