public async Task <TaxRateModel> AddTaxRate(TaxRateModel model) { TaxRateModel taxRateModel = null; try { ScheduleType stype; if (Enum.TryParse <ScheduleType>(model.ScheduleType, out stype)) { taxRateModel = new TaxRateModel(); taxRateModel.MunicipalityName = model.MunicipalityName; taxRateModel.ScheduleType = stype.ToString(); taxRateModel.Year = model.Year; taxRateModel.TaxRate = model.TaxRate; taxRateModel.StartDate = model.StartDate; taxRateModel.EndDate = model.EndDate; } if (taxRateModel != null) { bool isexist = false; switch (stype) { case ScheduleType.Daily: isexist = _taxRateRepository.IsExistDaily(taxRateModel); break; case ScheduleType.Weekly: isexist = _taxRateRepository.IsExistDaily(taxRateModel); break; case ScheduleType.Monthly: isexist = _taxRateRepository.IsExistDaily(taxRateModel); break; } if (!isexist) { await _taxRateRepository.AddScheduleTaxRate(taxRateModel); } else { taxRateModel = null; } } } catch (Exception ex) { throw ex; } return(taxRateModel); }
public async Task <ActionResult <TaxRateModel> > AddTaxRate(TaxRateModel taxRateModel) { try { var result = await _taxRateRepository.AddScheduleTaxRate(taxRateModel); if (result == null) { return(new ObjectResult("Either Record already exists or input values are wrong")); } } catch (Exception ex) { return(new ObjectResult(ex.Message)); } return(Ok(taxRateModel)); }