public void AddFAQuestion(FAQuestion q) => fAQuestions.Add(q);
public async Task UpdateFAQuestion(FAQuestion FAQuestion) { _ctx.FAQuestions.Update(FAQuestion); await _ctx.SaveChangesAsync(); }
private void AddTestData() { Member m1 = new Member { Name = "Michelangelo di Lodovico Buonarroti Simoni", Password = "******", Title = "Member" }; Member m2 = new Member { Name = "Donato di Niccolò di Betto Bardi", Password = "******", Title = "Member" }; Member m3 = new Member { Name = "Leonardo da Vinci", Password = "******", Title = "Member" }; Member m4 = new Member { Name = "Raffaello Sanzio da Urbino", Password = "******", Title = "Member" }; AddMember(m1); AddMember(m2); AddMember(m3); AddMember(m4); // Make Forum Questions ForumQuestion fq1 = new ForumQuestion { Questioner = m1, DateAdded = new DateTime(2017, 1, 1), QuestionHeader = "Year, Month, and Day parameters " + "describe an un-representable DateTime Exception", QuestionBody = "I'm getting this error when I try to " + "print a DateTime object on my website.", }; // Populate keywords fq1.FindKeywords(); ForumQuestion fq2 = new ForumQuestion { Questioner = m2, DateAdded = new DateTime(2019, 4, 7), QuestionHeader = "Null pointer references when the .cshtml page tries to render Comment objects.", QuestionBody = "The debugger shows that there is a comment object, but the user name is Null.", }; // Populate keywords fq2.FindKeywords(); // Make Replies Reply r1 = new Reply() { DateAdded = new DateTime(2017, 1, 4), Responder = m3, ReplyBody = "Have you tried adding a .ToString?", }; Reply r2 = new Reply() { DateAdded = new DateTime(2017, 1, 5), Responder = m4, ReplyBody = "Try adding a date string formatter. I used this " + " to get year-month-day: dateObj.ToString('yyyy - MM - dd')", }; // Find keywords in replies r1.FindKeywords(); r2.FindKeywords(); // Add replies to forum questions AddReply(fq1, r1, m3); AddReply(fq1, r2, m4); // Add replies to context AddForumQuestion(fq1, m1); AddForumQuestion(fq2, m2); // Make FAQs/Kbs FAQuestion faq1 = new FAQuestion { // Date DateAdded = new DateTime(2019, 2, 28), // Title QuestionHeader = "What is a method and why do I have to call it?", // Body QuestionBody = "A method is a code block that contains a series " + "of statements. A program causes the statements to be executed " + "by calling the method and specifying any required method " + "arguments. In C#, every executed instruction is performed in " + "the context of a method. The Main method is the entry point " + "for every C# application and it's called by the common " + "language runtime (CLR) when the program is started. " + "The method definition specifies the names and types of any" + " parameters that are required. When calling code calls the" + " method, it provides concrete values called arguments for each" + " parameter. The arguments must be compatible with the " + "parameter type but the argument name (if any) used in the " + "calling code doesn't have to be the same as the parameter " + "named defined in the method. ", }; FAQuestion faq2 = new FAQuestion { DateAdded = new DateTime(2019, 10, 9), // Title QuestionHeader = "What is the difference between ref & out " + "parameters?", // Body QuestionBody = "An argument passed as ref must be initialized" + " before passing to the method whereas the out parameter needs not " + "to be initialized before passing to a method. ", }; FAQuestion faq3 = new FAQuestion { DateAdded = new DateTime(2018, 3, 15), // Title QuestionHeader = "What is the difference between public, " + "static, and void?", // Body QuestionBody = "Public declared variables or methods are " + "accessible anywhere in the application. Static declared " + "variables or methods are globally accessible without creating " + "an instance of the class. Static member are by default not" + " globally accessible it depends upon the type of access " + "modified used. The compiler stores the address of the method " + "as the entry point and uses this information to begin" + " execution before any objects are created. And Void is a " + "type modifier that states that the method or variable does " + "not return any value. ", }; // Add keywords faq1.FindKeywords(); faq2.FindKeywords(); faq3.FindKeywords(); // Add FAQs to context AddFAQuestion(faq1); AddFAQuestion(faq2); AddFAQuestion(faq3); // Make Tutors Tutor t1 = new Tutor { UserName = "******", Password = "******", Title = "Moderator", Expertise = { "C#", "Python" } }; AddTutor(t1); }