コード例 #1
0
ファイル: RecipesTests.cs プロジェクト: No0zZy/Cursed
        public async void UpdateRecipe_AtInitializedDbTable_UpdatedRecipeEqualExpectedRecipe()
        {
            // arrange
            var recipe = GetRecipe();

            fixture.db.Add(recipe);
            await fixture.db.SaveChangesAsync();

            var expected = new Recipe
            {
                Id                = recipe.Id,
                Content           = "Tested content",
                GovermentApproval = true,
                TechApproval      = false
            };

            // act
            await logic.UpdateDataModelAsync(expected);

            // assert
            var actual = await fixture.db.Recipe.FirstOrDefaultAsync(i => i.Id == expected.Id);

            Assert.Equal(expected.Id, actual.Id);
            Assert.Equal(expected.Content, actual.Content);
            Assert.Equal(expected.GovermentApproval, actual.GovermentApproval);
            Assert.Equal(expected.TechApproval, actual.TechApproval);
        }
コード例 #2
0
        public async Task <IActionResult> EditSingleItem(Recipe model)
        {
            var statusMessage = await logicValidation.CheckUpdateDataModelAsync(model.Id);

            if (statusMessage.IsCompleted)
            {
                await logic.UpdateDataModelAsync(model);

                await logProvider.AddToLogAsync($"Updated recipe information (Id: {model.Id}).");

                return(RedirectToRoute(RecipesRouting.Index));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }