public Subquestion Post3([FromBody] QuestioncloseViewModel model) { //System.Console.WriteLine("subjectId" + subjectId); var questionsclosedata = new Subquestion { SubjectId = model.SubjectId, Name = model.Name, Type = "คำถามปลายปิด" }; _context.Subquestions.Add(questionsclosedata); _context.SaveChanges(); foreach (var questionclosechoice in model.inputanswerclose2) { var Subquestionchoiceclosedata = new SubquestionChoice { SubquestionId = questionsclosedata.Id, Name = questionclosechoice.answerclose }; _context.SubquestionChoices.Add(Subquestionchoiceclosedata); _context.SaveChanges(); } return(questionsclosedata); }
public Subquestion Post2(long subjectId, string name) { System.Console.WriteLine("subjectId" + subjectId); var questionsopendata = new Subquestion { SubjectId = subjectId, Name = name, Type = "คำถามปลายเปิด" }; _context.Subquestions.Add(questionsopendata); _context.SaveChanges(); return(questionsopendata); }
public Subquestion Post(string name, long subjectid) { //var date = DateTime.Now; var subquestiondata = new Subquestion { Name = name, SubjectId = subjectid, //Answer = "", //CreatedAt = date }; _context.Subquestions.Add(subquestiondata); _context.SaveChanges(); return(subquestiondata); }