Esempio n. 1
0
        public ActionResult Edit([Bind(Include = "Id,Name")] Country country)
        {
            CountryValidator validar = new CountryValidator();
            ValidationResult Result  = validar.Validate(country);

            if (!Result.IsValid)
            {
                foreach (ValidationFailure item in Result.Errors)
                {
                    ModelState.AddModelError(item.PropertyName, item.ErrorMessage);
                }
                return(View(country));
            }
            else
            {
                var objCountry = countryService.Actualizar(country);
                return(View(country));
            }
            //if (ModelState.IsValid)
            //{
            //    db.Entry(country).State = EntityState.Modified;
            //    db.SaveChanges();
            //    return RedirectToAction("Index");
            //}
            //return View(country);
        }