Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 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));
 }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 6
0
 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));
 }
Ejemplo n.º 7
0
 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));
 }
Ejemplo n.º 9
0
        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));
        }