/* * Thêm một kì thi */ public AjaxResult AddExamPeriod([FromBody] List <string> ExamPeriod) { var z = HttpContext.Session.GetString("AdminId"); if (z == null) { Response.Redirect("https://localhost:44302/Main/Login"); return(null); } var Exam = new MainRepository(); AjaxResult ajaxResult = new AjaxResult(); var begin = Convert.ToInt32(ExamPeriod[1]); var end = Convert.ToInt32(ExamPeriod[2]); if (end - begin > 1 == true || begin < 0 == true || end < 0 == true || begin >= end == true) { ajaxResult.Message = "3"; return(ajaxResult); } else { string out_mess = ""; Exam.AddExamPeriod(ExamPeriod[0].ToString(), Convert.ToInt32(ExamPeriod[1]), Convert.ToInt32(ExamPeriod[2]), out out_mess); if (out_mess == "1") { ajaxResult.Message = "1"; return(ajaxResult); } else { Exam.conn.Close(); var x = Exam.GetExamsId(ExamPeriod[0].ToString(), out out_mess); List <string> id = new List <string>(); id.Add(x.ToString()); id.Add(ExamPeriod[0]); id.Add(ExamPeriod[1].ToString()); id.Add(ExamPeriod[2].ToString()); ajaxResult.Data = id; ajaxResult.Message = "0"; return(ajaxResult); } } }