public void EditTs(TS ts) { if (!ModelState.IsValid) { var message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage)); throw new Exception("Модель не валидна: " + message); } else { repo.Edit(ts, out status); foreach (var d in ModelState.Select(x => x.Value.Errors).Where(y => y.Count > 0).ToList()) { ; } if (status != "ok") { throw new Exception(status); } } }