//, string sourceName, string sourceTypeName, string authorFirstName, string authorLastName, string comment = "Default comment") public static Snippet CreateKb(string text, string pageOrLocation) { using (var db = new SnippetAppDB()) { Snippet sp = new Snippet(); sp.Text = text; sp.PageorLocation = pageOrLocation; db.Snippets.Add(sp); //Source sourcevar = new Source(); //sourcevar.SourceName = sourceName; //db.Sources.Add(sourcevar); //Comments commentsvar = new Comments(); //commentsvar.CommentsText = comment; //if (comment != "Default comment") //{ //} //db.Comments.Add(commentsvar); //SourceType sourcetypevar = new SourceType(); //sourcetypevar.SourceTypeName = sourceTypeName; //db.SoureTypes.Add(sourcetypevar); //Author authorvar = new Author(); //authorvar.AuthorFirstName = authorFirstName; //authorvar.AuthorLastName = authorLastName; //db.Authors.Add(authorvar); db.SaveChanges(); return sp; } }
public static Snippet CreateKb(string text, string pageOrLocation)//, string sourceName, string sourceTypeName, string authorFirstName, string authorLastName, string comment = "Default comment") { using (var db = new SnippetAppDB()) { Snippet sp = new Snippet(); sp.Text = text; sp.PageorLocation = pageOrLocation; db.Snippets.Add(sp); //Source sourcevar = new Source(); //sourcevar.SourceName = sourceName; //db.Sources.Add(sourcevar); //Comments commentsvar = new Comments(); //commentsvar.CommentsText = comment; //if (comment != "Default comment") //{ //} //db.Comments.Add(commentsvar); //SourceType sourcetypevar = new SourceType(); //sourcetypevar.SourceTypeName = sourceTypeName; //db.SoureTypes.Add(sourcetypevar); //Author authorvar = new Author(); //authorvar.AuthorFirstName = authorFirstName; //authorvar.AuthorLastName = authorLastName; //db.Authors.Add(authorvar); db.SaveChanges(); return(sp); } }
public static Snippet GetSnippetByID(int TextID) { using (var db = new SnippetAppDB()) { var snippetlist = db.Snippets.Where(a => a.TextID == TextID).FirstOrDefault(); return(snippetlist); } }
public static Snippet DeleteKb(string text, string pageOrLocation)//, string sourceName, string sourceTypeName, string authorFirstName, string authorLastName, string comment = "Default comment") { using (var db = new SnippetAppDB()) { Snippet sp = new Snippet(); sp.Text = text; sp.PageorLocation = pageOrLocation; db.Snippets.Remove(sp); db.SaveChanges(); return(sp); } }
public static List <Snippet> SearchForSnippets(string query) { using (var context = new SnippetAppDB()) { var q = context.Snippets.AsQueryable(); string qs = query; { q = q.Where(x => x.Text.Contains(qs)); } var result = q.ToList(); return(result); } }
//everything below was added after 10.4 class public static Author[] GetAllAuthors(int authorID) { using (var db = new SnippetAppDB()) { var authorlist = db.Authors.Where(a => a.AuthorID == authorID); return(authorlist.ToArray()); } }
public static List<Snippet> SearchForSnippets(string query) { using (var context = new SnippetAppDB()) { var q = context.Snippets.AsQueryable(); string qs = query; { q = q.Where(x => x.Text.Contains(qs)); } var result = q.ToList(); return result; } }
public static Snippet GetSnippetByID(int TextID) { using (var db = new SnippetAppDB()) { var snippetlist = db.Snippets.Where(a => a.TextID == TextID).FirstOrDefault(); return snippetlist; } }
//everything below was added after 10.4 class public static Author[] GetAllAuthors(int authorID) { using (var db = new SnippetAppDB()) { var authorlist = db.Authors.Where(a => a.AuthorID == authorID); return authorlist.ToArray(); } }
//, string sourceName, string sourceTypeName, string authorFirstName, string authorLastName, string comment = "Default comment") public static Snippet EditKb(string text, string pageOrLocation) { using (var db = new SnippetAppDB()) { Snippet sp = new Snippet(); sp.Text = text; sp.PageorLocation = pageOrLocation; db.Snippets.Add(sp); db.SaveChanges(); return sp; } }