예제 #1
0
        public async Task <IActionResult> Edit(EditProteinProductInputModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(inputModel));
            }

            await this.productsService
            .EditProductAsync <Protein, EditProteinProductInputModel>(
                inputModel,
                inputModel.Image,
                inputModel.Id);

            return(this.Redirect(WebConstants.AdministrationAllProductsPath));
        }
        public async Task DeleteWithInvalidId_ShouldThrow()
        {
            this.Initialize();
            this.SeedProducts();

            var protModel = new EditProteinProductInputModel()
            {
                Name                = Proteinname + "edited",
                Price               = Price2,
                Description         = ProteinDesciption,
                Directions          = ProteinDirections,
                Type                = ProteinType.Whey,
                IsSuatableForVegans = false,
                EnergyPerServing    = 0,
                ProteinPerServing   = 0,
                Fibre               = 0,
                Salt                = 0,
                Carbohydrate        = 0,
                Fat = 0
            };

            await Assert.ThrowsAsync <ProductNotFoundException>(() =>
                                                                this.service.EditProductAsync <Protein, EditProteinProductInputModel>(protModel, image, ProductId - 1));
        }