protected async void btn_AddExam(object sender, EventArgs e)
        {
            bool           res        = true;
            List <string>  questions  = new List <string>();
            List <TextBox> listofques = new List <TextBox>();
            List <TextBox> op1s       = new List <TextBox>();
            List <TextBox> op2s       = new List <TextBox>();
            List <TextBox> op3s       = new List <TextBox>();
            List <TextBox> op4s       = new List <TextBox>();
            List <TextBox> answers    = new List <TextBox>();

            for (int i = 0; i < noq; i++)
            {
                TextBox q   = (TextBox)this.Master.FindControl("MainContent").FindControl("ques" + i.ToString());
                TextBox op1 = (TextBox)this.Master.FindControl("MainContent").FindControl("op1" + i.ToString());
                TextBox op2 = (TextBox)this.Master.FindControl("MainContent").FindControl("op2" + i.ToString());
                TextBox op3 = (TextBox)this.Master.FindControl("MainContent").FindControl("op3" + i.ToString());
                TextBox op4 = (TextBox)this.Master.FindControl("MainContent").FindControl("op4" + i.ToString());
                TextBox ans = (TextBox)this.Master.FindControl("MainContent").FindControl("ans" + i.ToString());

                if (q.Text == string.Empty || op1.Text == string.Empty || op2.Text == string.Empty || op3.Text == string.Empty || op4.Text == string.Empty || ans.Text == string.Empty)
                {
                    Label1.Text = "All questions are mandatory";
                    return;
                }
                listofques.Add(q);
                op1s.Add(op1);
                op2s.Add(op2);
                op3s.Add(op3);
                op4s.Add(op4);
                answers.Add(ans);
            }

            // task of adding questions to database begins
            for (int i = 0; i < noq; i++)
            {
                Question ques = new Question
                {
                    QuestionVal = listofques[i].Text,
                    Option1     = op1s[i].Text,
                    Option2     = op2s[i].Text,
                    Option3     = op3s[i].Text,
                    Option4     = op4s[i].Text,
                    Answer      = answers[i].Text
                };

                using (var client = new HttpClient())
                {
                    string jsonString = string.Empty;
                    client.BaseAddress = new Uri(baseAddress);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    HttpResponseMessage response = await client.PostAsJsonAsync("api/question/", ques);

                    if (response.IsSuccessStatusCode)
                    {
                        jsonString = response.Content.ReadAsStringAsync().Result;
                        bool resques = bool.Parse(jsonString);
                        questions.Add(ques.QuestionVal);
                        Label1.Text += resques.ToString();
                        res          = res && resques;
                    }
                }

                //bool resques = questionServiceClient.AddQuestion(ques);
                //questions.Add(ques.QuestionVal);
                //Label1.Text += resques.ToString();
                //res = res && resques;
            }

            User     loggedInUser = (User)Session["loggedInUser"];
            string   name         = (string)Session["User"];
            DateTime date         = (DateTime)Session["date"];

            Online_Examination_Client.Models.Exam exam = new Online_Examination_Client.Models.Exam
            {
                DueTime   = date,
                Questions = new List <string>(questions.ToArray()),
                Teacher   = name
            };

            using (var client = new HttpClient())
            {
                string jsonString = string.Empty;
                client.BaseAddress = new Uri(baseAddress);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.PostAsJsonAsync("api/exam/add", exam);

                if (response.IsSuccessStatusCode)
                {
                    bool resexam = bool.Parse(response.Content.ReadAsStringAsync().Result);
                    Label1.Text += resexam.ToString();
                    res          = res && resexam;
                    if (res)
                    {
                        Response.Redirect("TeacherHome", false);
                    }
                    else
                    {
                        Label1.Text = "Error";
                    }
                }
                else
                {
                    Label1.Text = "Error";
                }
            }

/*            bool resexam = examserviceclient.addexam(exam);
 *          label1.text += resexam.tostring();
 *          res = res && resexam;
 *          if (res)
 *          {
 *              response.redirect("teacherhome");
 *          }
 *          else
 *          {
 *              label1.text = "error";
 *          }*/
        }
        protected async void Page_Load(object sender, EventArgs e)
        {
            ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
            examid = Convert.ToInt32(Request.QueryString["id"]);

            //questionServiceClient = new QuestionService.QuestionServiceClient();
            //examServiceClient = new ExamService.ExamServiceClient();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseAddress);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                string url = "api/exam/" + examid.ToString();
                HttpResponseMessage response = await client.GetAsync(url);

                if (response.IsSuccessStatusCode)
                {
                    var readTask = response.Content.ReadAsAsync <Online_Examination_Client.Models.Exam>();
                    readTask.Wait();

                    Online_Examination_Client.Models.Exam exam = readTask.Result;

                    int noq = exam.Questions.Count;
                    for (int i = 0; i < noq; i++)
                    {
                        string             question = exam.Questions[i];
                        HtmlGenericControl d        = getCustomDiv("row my-3");
                        HtmlGenericControl d1       = getCustomDiv("offset-4 col-6");
                        d.Controls.Add(d1);
                        HtmlGenericControl q = new HtmlGenericControl("h4");
                        q.Attributes.Add("class", "font-weight-bold form-label");
                        q.InnerText = (i + 1).ToString() + " " + question;

                        /*client.BaseAddress = new Uri(baseAddress);
                         * client.DefaultRequestHeaders.Accept.Clear();
                         * client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                         */
                        response = await client.PostAsJsonAsync("api/question/find-question/", question);

                        if (response.IsSuccessStatusCode)
                        {
                            var readTask1 = response.Content.ReadAsAsync <Question>();
                            readTask1.Wait();
                            Question ques = readTask1.Result;

                            questions.Add(ques);
                            RadioButtonList rdr = new RadioButtonList();
                            rdr.Items.Add(new ListItem(ques.Option1, ques.Option1));
                            rdr.Items.Add(new ListItem(ques.Option2, ques.Option2));
                            rdr.Items.Add(new ListItem(ques.Option3, ques.Option3));
                            rdr.Items.Add(new ListItem(ques.Option4, ques.Option4));
                            rdr.ID       = "que" + i.ToString();
                            rdr.CssClass = "mx-3 p-3";
                            d.Controls.Add(q);
                            d.Controls.Add(rdr);
                            this.Master.FindControl("MainContent").FindControl("ques").Controls.Add(d);
                        }
                        //QuestionService.Question ques = questionServiceClient.FindQuestion(question);
                    }
                }
            }

            //ExamService.Exam exam = examServiceClient.GetExam(examid);
        }