public ActionResult GridViewTranslateWordsPartialUpdate(CC.Models.Database.TranslateWord item) { var model = dbTranslateWords.TranslateWords; if (ModelState.IsValid) { try { var modelItem = model.FirstOrDefault(it => it.word == item.word); if (modelItem != null) { this.UpdateModel(modelItem); dbTranslateWords.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewTranslateWordsPartial", model.ToList())); }
public ActionResult GridViewTranslateWordsPartialAddNew(CC.Models.Database.TranslateWord item) { var model = dbTranslateWords.TranslateWords; if (ModelState.IsValid) { try { model.Add(item); dbTranslateWords.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewTranslateWordsPartial", model.ToList())); }