Example #1
0
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction(nameof(Error), new { message = "Id não fornecido" }));
            }

            var obj = await _vendedorService.FindByIDAsync(id.Value);

            if (obj == null)
            {
                return(RedirectToAction(nameof(Error), new { message = "Id não encontrado" }));
            }

            return(View(obj));
        }
        // GET: Vendedor/Details/
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var vendedor = await _vendedorService.FindByIDAsync(id.Value);


            if (vendedor == null)
            {
                return(NotFound());
            }

            return(View(vendedor));
        }
        //O '?' no parâmetro indica que o mesmo é opcional
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction(nameof(Error), new { message = "ID não informado." }));
            }

            var vend = await _vendedorService.FindByIDAsync(id.Value);

            if (vend == null)
            {
                return(RedirectToAction(nameof(Error), new { message = "ID não encontrado." }));
            }

            else
            {
                return(View(vend));
            }
        }