예제 #1
0
        public async Task <IActionResult> EditProduto(int id)
        {
            string statusModel = null;
            var    marcas      = await _marcaAppServices.GetAllAsync();

            var materiais = await _materialAppServices.GetAllAsync();

            var listaFotos = await _produtoFotoAppServices.RetornarListaFotoInput(id);

            var cores = await _produtoCorAppServices.GetByProdutoAsync(id, null);

            var listaCores = await _produtoCorAppServices.RetornarListaDeCorDoProduto(id, null);

            var produto = await _produtoAppServices.GetByIdAsync(id);

            var corSelect = await _corAppServices.GetAllAsync();

            if (TempData["Error"] != null)
            {
                statusModel = "Error";
                ModelState.AddModelError(string.Empty, TempData["Error"].ToString());
            }
            else if (TempData["Success"] != null)
            {
                statusModel = "Success";
                ModelState.AddModelError(string.Empty, TempData["Success"].ToString());
            }

            return(View("Edit", new ProdutoEditViewModel(marcas, materiais, listaFotos, cores, listaCores, corSelect, produto, id, statusModel)));
        }