static void Main(string[] args) { int id = 0, menuoption = 0; bool exit == false; Console.WriteLine("Welcome! Select one of the following options"); while exit == false { Console.Clear(); Console.WriteLine(id + " Questions added"); Console.WriteLine("1. Add question"); Console.WriteLine("2. Exit"); menuoption = Convert.ToInt32(Console.ReadLine()); switch (menuoption) { case 1: Question.AddQuestion(id); break; case 2: exit = true; break; default Console.WriteLine("Please select a valid option"); break; } } }
protected void BtnAddQuestion_Click(object sender, EventArgs e) { if (this.Page.IsPostBack == true) { if (this.IsValid == true) { //throw new Exception("hi"); int QuestionId = Question.AddQuestion(DateTime.Now, TxtQuestion.Text, DdlRelatedTo.SelectedValue, int.Parse(Request.QueryString["Id"])); TxtQuestion.Text = string.Empty; DdlRelatedTo.SelectedIndex = 0; DivAddQuestionModal.Visible = false; this.Form.DefaultButton = string.Empty; ShowQuestions(); } } }
// POST api/<controller> public int Post([FromBody] Question q) { return(q.AddQuestion()); }