public void AddHistory(History history) { using (var db = new MysqlDataContext()) { history.HistoryId = db.History.Max(h => h.HistoryId) + 1; db.Add(history); db.SaveChanges(); } }
public void AddOwnComment(OwnComments owncomment) { using (var db = new MysqlDataContext()) { owncomment.CommentId = db.OwnComment.Max(o => o.CommentId) + 1; db.Add(owncomment); db.SaveChanges(); } }
public bool DeleteOwnComment(int id) { using (var db = new MysqlDataContext()) { var own = db.OwnComment.FirstOrDefault(o => o.CommentId == id); if (own == null) { return(false); } db.Remove(own); return(db.SaveChanges() > 0); } }
public bool DeleteHistory(int id) { using (var db = new MysqlDataContext()) { var history = db.History.FirstOrDefault(h => h.HistoryId == id); if (history == null) { return(false); } db.Remove(history); return(db.SaveChanges() > 0); } }
public bool UpdateHistory(History history) { using (var db = new MysqlDataContext()) { try { db.Attach(history); db.Entry(history).State = EntityState.Modified; return(db.SaveChanges() > 0); } catch (DbUpdateConcurrencyException) { return(false); } } }
public bool UpdateOwnComment(OwnComments own) { using (var db = new MysqlDataContext()) { try { db.Attach(own); db.Entry(own).State = EntityState.Modified; return(db.SaveChanges() > 0); } catch (DbUpdateConcurrencyException) { return(false); } } }