public async Task <IHttpActionResult> PostExam_attemp(Exam_attemp exam_attemp) { db.Configuration.ProxyCreationEnabled = false; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Exam_attemp.Add(exam_attemp); await db.SaveChangesAsync(); var dto = new { id = exam_attemp.id, UserId = exam_attemp.UserId, ExamId = exam_attemp.ExamId, attempt = exam_attemp.attempt, SumGrade = exam_attemp.SumGrade, TimeStart = exam_attemp.TimeStart, TimeFinish = exam_attemp.TimeFinish, Preview = exam_attemp.Preview }; return(CreatedAtRoute("DefaultApi", new { id = exam_attemp.id }, dto)); }
public async Task <IHttpActionResult> PutExam_attemp(int id, Exam_attemp exam_attemp) { db.Configuration.ProxyCreationEnabled = false; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != exam_attemp.id) { return(BadRequest()); } db.Entry(exam_attemp).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exam_attempExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetExam_attemp(int id) { Exam_attemp exam_attemp = await db.Exam_attemp.FindAsync(id); if (exam_attemp == null) { return(NotFound()); } return(Ok(exam_attemp)); }
public async Task <IHttpActionResult> DeleteExam_attemp(int id) { Exam_attemp exam_attemp = await db.Exam_attemp.FindAsync(id); if (exam_attemp == null) { return(NotFound()); } db.Exam_attemp.Remove(exam_attemp); await db.SaveChangesAsync(); return(Ok(exam_attemp)); }