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 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); } }
//, 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; } }
//, 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; } }