public async Task <IActionResult> PutTest([FromRoute] int id, [FromBody] Test test) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != test.ID) { return(BadRequest()); } _context.Entry(test).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TestExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutQuestion(int id, Question question) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != question.Id) { return(BadRequest()); } db.Entry(question).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!QuestionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "Id,QuestionText,AnswerDescription,UserId")] Question question) { if (ModelState.IsValid) { db.Entry(question).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(question)); }
public ActionResult Edit([Bind(Include = "Id,EslLevelName")] EslLevel eslLevel) { if (ModelState.IsValid) { db.Entry(eslLevel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eslLevel)); }
public ActionResult Edit([Bind(Include = "Id,GrammaCategoryName")] GrammaCategory grammaCategory) { if (ModelState.IsValid) { db.Entry(grammaCategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(grammaCategory)); }
public ActionResult Edit([Bind(Include = "Id,LexicTypeName")] LexicType lexicType) { if (ModelState.IsValid) { db.Entry(lexicType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lexicType)); }
public ActionResult Edit([Bind(Include = "Id,Name,Description")] Theme theme) { if (ModelState.IsValid) { db.Entry(theme).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(theme)); }
public ActionResult Edit([Bind(Include = "Id,GrammaCategory,EslLevel,Body,Answer")] GrammaQuestion grammaQuestion) { if (ModelState.IsValid) { grammaQuestion.ModifiedAt = DateTime.Now; db.Entry(grammaQuestion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(grammaQuestion)); }
public IHttpActionResult PutUserPerformance(string userEmail, UserPerformance userPerformance) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (userEmail != userPerformance.UserId) { return(BadRequest()); } UserPerformance currentPerformance = db.UserPerformances.First(x => x.UserId == userEmail); if (currentPerformance != null) { userPerformance.CorrectAnswerCount += currentPerformance.CorrectAnswerCount; userPerformance.TotalGamesCount += currentPerformance.TotalGamesCount; userPerformance.TotalQuestions += currentPerformance.TotalQuestions; } db.Entry(userPerformance).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserPerformanceExists(userPerformance.UserId)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }