Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id, Title")] QuizViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var getOperation = await _bo.ReadAsync((Guid)id);

                if (!getOperation.Success)
                {
                    return(OperationErrorBackToIndex(getOperation.Exception));
                }
                if (getOperation.Result == null)
                {
                    return(RecordNotFound());
                }
                var result = getOperation.Result;
                result.Title = vm.Title;
                var updateOperation = await _bo.UpdateAsync(result);

                if (!updateOperation.Success)
                {
                    return(OperationErrorBackToIndex(updateOperation.Exception));
                }
                else
                {
                    return(OperationSuccess("The record was successfuly updated"));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 2
0
        public void TestUpdateQuizAsync()
        {
            BoraNowSeeder.Seed();
            var qbo     = new QuizBusinessObject();
            var resList = qbo.List();

            var quiz    = resList.Result.FirstOrDefault();
            var newQuiz = new Quiz("BoraNow Quiz");

            quiz.Title = newQuiz.Title;

            var resUpdate = qbo.UpdateAsync(quiz).Result;

            resList = qbo.ListAsync().Result;
            Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().Title == quiz.Title);
        }