public ActionResult Create() { var model = new ShippingMethodEditViewModel(); ViewBag.ShippingZoneId = new SelectList(shippingZoneService.FindAll().ToList(), "Id", "Name"); return(View(model)); }
public ShippingZoneViewModelValidator(IShippingZoneService shippingZoneService) { RuleFor(z => z.Name).NotEmpty(); RuleFor(z => z).Must( z => !shippingZoneService.FindAll().Any(d => d.Id != z.Id && d.Name == z.Name)) .WithName("Name") .WithMessage("Name is already used".TA()); }
public ActionResult Index() { var model = new List <ShippingZoneIndexViewModel>(); List <ShippingZone> shippingZones = shippingZoneService.FindAll().ToList(); foreach (ShippingZone zone in shippingZones) { var zoneView = Mapper.Map <ShippingZoneIndexViewModel>(zone); model.Add(zoneView); } return(View(model)); }