public ActionResult Edit(int id, ContentData model) { var contentData = _dataContext.ContentDatas.Single(m => m.Id == id); contentData.Content = model.Content; _dataContext.SaveChanges(); return RedirectToAction("Detail", new {contentData.Id}); }
private ContentData GetContentData(string actionName, string controllerName) { var model = _dataContext.ContentDatas .Where(m => m.ActionName == actionName) .Where(m => m.ControllerName == controllerName) .SingleOrDefault(); if (model == null) { model = new ContentData { ActionName = actionName, ControllerName = controllerName, Name = actionName, Content="Content goes here." }; _dataContext.ContentDatas.Add(model); _dataContext.SaveChanges(); } return model; }