public TESTRATINGS ToEntity(TESTRATINGS testratings) { testratings.ID = this.id; testratings.FACT = this.fact; return(testratings); }
public ActionResult UpdateForGrid([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <TestRatingViewModel> ratings) { if (ratings != null && ModelState.IsValid) { foreach (var rating in ratings) { TESTRATINGS entity = db.TESTRATINGS.Get().FirstOrDefault(r => r.ID == rating.id); if (entity != null) { entity = rating.ToEntity(entity); try { db.TESTRATINGS.Update(entity); } catch (Exception ex) { ModelState.AddModelError("TESTRATINGS", ex.Message); } } else { ModelState.AddModelError("TESTRATINGS", String.Format("Рейтинг теста '{0}' не обнаружена в базе данных!", rating.rating)); } } } return(Json(ratings.ToDataSourceResult(request, ModelState))); }