예제 #1
0
 public TaxRateEditViewModelValidator(ITaxRateService taxRateService)
 {
     RuleFor(r => r.Amount).GreaterThanOrEqualTo(0);
     RuleFor(r => r.TaxZoneId).NotEmpty().WithMessage("Please select a tax zone".TA());
     RuleFor(r => r.Name).NotEmpty();
     RuleFor(r => r).Must(
         r => !taxRateService.FindAll().Any(d => d.Id != r.Id && d.Name == r.Name))
     .WithName("Name")
     .WithMessage("Name is already used".TA());
 }
예제 #2
0
        public ActionResult Index()
        {
            var model = new List <TaxRateIndexViewModel>();

            if (settingService.Get <bool>(SettingField.ShowTaxRateTutorial))
            {
                settingService.Set(SettingField.ShowTaxRateTutorial, false);
            }

            List <TaxRate> taxRates = taxRateService.FindAll().ToList();

            foreach (TaxRate rate in taxRates)
            {
                var rateView = Mapper.Map <TaxRateIndexViewModel>(rate);

                model.Add(rateView);
            }

            return(View(model));
        }