public void Test_CountryCreateOrUpdate_Validate() { var value = new CountryCreateOrUpdate(); value.Validate(); Assert.AreEqual(2, value.Errors.Count, "Errors"); }
public ActionResult Create(CountryCreateOrUpdate value) { if (value == null) { throw new ArgumentNullException("value"); } var country = this.CountryService.Create(); var privilege = new CountryPrivilege(); if (!privilege.CanCreate(country)) { return NotAuthorized(); } value.Validate(); if (value.IsValid) { value.ValueToModel(country); this.CountryService.InsertOrUpdate(country); value = new CountryCreateOrUpdate(country); value.SuccessMessage(Messages.CountryCreated.FormatInvariant(country.Title)); } else { value.CopyToModel(ModelState); } return base.View(Views.Update, value); }