public static int AddOrUpdateTopic(Topic t) { int ret; //remove the topics from cache CacheManager.RemoveItem("topics"); using (db = new topicsEF()) { var topic = db.Topics.Where(x => x.TopicID == t.TopicID).FirstOrDefault(); if (topic == null) { db.Topics.Add(t); ret = db.SaveChanges(); } else { topic.Title = t.Title; topic.DateUpdated = DateTime.Now; ret = db.SaveChanges(); } return(ret); } }
public static int AddComment(Comment c) { int ret = 0; using (db = new topicsEF()) { if (c == null) { ret = 0; } db.Comments.Add(c); ret = db.SaveChanges(); } return(ret); }