public bool CreateNewsArticle(TblNewsArticles tblNewsArticle) { try { tblNewsArticle.CreatedDate = DateTime.Now; tblNewsArticle.ModifiedDate = DateTime.Now; tblNewsArticle.UserId = 1; _xbmcDatabase.TblNewsArticles.InsertOnSubmit(tblNewsArticle); _xbmcDatabase.SubmitChanges(); return true; } catch { return false; } }
public bool SaveNewsArticle(TblNewsArticles newsArticle) { try { TblNewsArticles tblNewsArticle = _xbmcDatabase.TblNewsArticles.Single(n => n.Id == newsArticle.Id); tblNewsArticle.Heading = newsArticle.Heading; tblNewsArticle.Body = newsArticle.Body; tblNewsArticle.Published = newsArticle.Published; tblNewsArticle.Frontpage = newsArticle.Frontpage; tblNewsArticle.ModifiedDate = DateTime.Now; _xbmcDatabase.SubmitChanges(); return true; } catch { return false; } }
public ActionResult Edit(TblNewsArticles newsArticle) { return _newsArticlesService.SaveNewsArticle(newsArticle) ? (ActionResult)RedirectToAction("Index") : View(); }