public ActionResult Create() { var model = new TaxRateEditViewModel(); foreach (var taxClass in taxClassService.FindAll().ToList()) { model.ClassRates.Add(new TaxClassRateEditViewModel { TaxClassId = taxClass.Id, TaxClassName = taxClass.Name }); } ViewBag.TaxZoneId = new SelectList(taxZoneService.FindAll().Where(z => z.IsActive).ToList(), "Id", "Name"); return(View(model)); }
public TaxZoneViewModelValidator(ITaxZoneService taxZoneService) { RuleFor(z => z.Name).NotEmpty(); RuleFor(z => z).Must( z => !taxZoneService.FindAll().Any(d => d.Id != z.Id && d.Name == z.Name)) .WithName("Name") .WithMessage("Name is already used".TA()); // TODO: Check for conflicts of countries or regions are defined in other tax zones }
public ActionResult Index() { var model = new List <TaxZoneIndexViewModel>(); List <TaxZone> taxZones = taxZoneService.FindAll().ToList(); foreach (TaxZone zone in taxZones) { var zoneView = Mapper.Map <TaxZoneIndexViewModel>(zone); model.Add(zoneView); } return(View(model)); }