public async Task <IActionResult> Post([FromBody] CreateExam command) { command.ExamId = Guid.NewGuid(); await _examService.CreateAsync(command.ExamId, command.Name, command.Description, command.StartDate, command.EndDate); return(Created($"/exams/{command.ExamId}", null)); }
public async Task <IActionResult> CreateExam([FromBody] CreateExam obj) { if (!ModelState.IsValid) { return(BadRequest()); } var course = await Context.Course.SingleOrDefaultAsync(ww => ww.CourseName == obj.CourseName); if (course == null) { return(NotFound(new { message = "there is no course with this name" })); } return(Ok(await DB.CreateExam(obj))); return(BadRequest()); }
//Create Exam public async Task <List <QuestionExam> > CreateExam(CreateExam createExam) { var userID = createExam.UserID; var CourseName = createExam.CourseName; var param1 = new SqlParameter("@CourseName", CourseName); param1.SqlDbType = System.Data.SqlDbType.NVarChar; var param2 = new SqlParameter("@UserID", userID); param2.SqlDbType = System.Data.SqlDbType.NVarChar; var param3 = new SqlParameter("@data", DateTime.Now); param3.SqlDbType = System.Data.SqlDbType.DateTime; var exam = await Db.QuestExam.FromSqlRaw("CreateExam @CourseName, @UserID , @data", param1, param2, param3).ToListAsync(); return(exam); }
/// <summary> /// Opens the create exam window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonCreateExam_Click_1(object sender, EventArgs e) { CreateExam createExamwin = new CreateExam(connection, group); createExamwin.Show(); }