public IOutcome<IEnumerable<Article>> Save(string connectionID, Thread thread) { ThreadSaver.SaveThread(thread); ArticleSaver.SaveArticles(connectionID, thread.Articles.ToList()); return Outcomes.Success<IEnumerable<Article>>() .WithValue(thread.Articles); }
public int SaveThread(Thread thread) { Thread existingThread = Db.Threads.FirstOrDefault(t => t.ID == thread.ID); if (existingThread.IsNotNull()) return existingThread.ID; Thread threadToSave = new Thread() { ID = thread.ID, NumArticles = thread.NumArticles, Link = thread.Link, TermsOfUse = thread.TermsOfUse, Subject = thread.Subject }; Db.Threads.Add(threadToSave); Db.SaveChanges(); return threadToSave.ID; }