public static bool Create(News news) { using (NewsEntities db = new NewsEntities()) { try { int len = 45; if (news.Text.Length <= len) { news.TextMain = news.Text.Remove(len) + " ..."; } else { news.TextMain = news.Text; } db.News.Add(news); db.SaveChanges(); db.Dispose(); } catch (Exception) { return(false); } } return(true); }
public static bool Edit(News news) { using (NewsEntities db = new NewsEntities()) { try { db.Entry(news).State = System.Data.EntityState.Modified; db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public static bool Edit(News news) { using (NewsEntities db = new NewsEntities()) { try { db.Entry(news).State = System.Data.EntityState.Modified; db.SaveChanges(); return true; } catch (Exception) { return false; } } }
public static bool Create(News news) { using (NewsEntities db = new NewsEntities()) { try { int len = 45; if (news.Text.Length <= len) news.TextMain = news.Text.Remove(len) + " ..."; else news.TextMain = news.Text; db.News.Add(news); db.SaveChanges(); db.Dispose(); } catch (Exception) { return false; } } return true; }