Exemplo n.º 1
0
        public ActionResult Update([FromBody] QuizQuestionViewModel c)
        {
            var currentResult = _bo.Read(c.Id);

            if (!currentResult.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            var current = currentResult.Result;

            if (current == null)
            {
                return(NotFound());
            }
            if (current.Question == c.Question && current.QuizId == c.QuizId)
            {
                return(new ObjectResult(HttpStatusCode.NotModified));
            }

            if (current.Question != c.Question)
            {
                current.Question = c.Question;
            }
            if (current.QuizId != c.QuizId)
            {
                current.QuizId = c.QuizId;
            }
            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            return(Ok());
        }
Exemplo n.º 2
0
        public void TestUpdateQuizQuestion()
        {
            BoraNowSeeder.Seed();
            var qqbo    = new QuizQuestionBusinessObject();
            var resList = qqbo.List();
            var item    = resList.Result.FirstOrDefault();

            var qbo = new QuizBusinessObject();

            var quiz = new Quiz("This quiz rocks");

            qbo.Create(quiz);

            item.QuizId   = quiz.Id;
            item.Question = "viewpoint?";


            var resUpdate = qqbo.Update(item);

            resList = qqbo.List();

            Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().Question == "viewpoint?" &&
                          resList.Result.First().QuizId == quiz.Id);
        }