public async Task <IActionResult> Edit(int id, Seller seller)
        {
            if (!ModelState.IsValid) // metodo para fazer a verificação do lado servidor
            {
                var dep = await _departmentService.FindAllAsync();

                var viewmodel = new SallerFormViewModel {
                    Seller = seller, Departments = dep
                };
                View(viewmodel);
            }

            if (id != seller.Id)
            {
                return(RedirectToAction(nameof(Error), new { message = "Not encontrado" }));
            }
            try
            {
                await _sellerService.UpdateAsync(seller);

                return(RedirectToAction(nameof(Index)));
            }
            catch (NotFoundException e)
            {
                return(RedirectToAction(nameof(Error), new { message = e.Message }));
            }
            catch (DbConcurrencyException)
            {
                return(RedirectToAction(nameof(Error), new { message = "Not encontrado" }));
            }
        }
        public async Task <IActionResult> Create()                     // retorna a visualização apos açao de apertar o botão create
        {
            var departments = await _departmentService.FindAllAsync(); // procurar todos os departamentos

            var depviewmodel = new SallerFormViewModel()
            {
                Departments = departments
            };                          // instanciando a classe e inicializando com os departamentos

            return(View(depviewmodel)); // mostrando a tela de departamentos
        }
        [ValidateAntiForgeryToken]                              // validação de segurança para seções abertas
        public async Task <IActionResult> Create(Seller seller) // criando o metodo crete post para envio apos a usuario apertar o botao enviar
        {
            if (!ModelState.IsValid)                            // metodo para fazer a verificação do lado servidor
            {
                var dep = await _departmentService.FindAllAsync();

                var viewmodel = new SallerFormViewModel {
                    Seller = seller, Departments = dep
                };
                View(viewmodel);
            }

            await _sellerService.InsertAsync(seller); // insere o seller no banco de dados acessando o metodo insert (SellerService)

            return(RedirectToAction(nameof(Index)));  // redireciona para a pagina index
        }
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction(nameof(Error), new { message = "Not encontrado" }));
            }
            var obj = await _sellerService.FindByIdAsync(id.Value);

            if (obj == null)
            {
                return(RedirectToAction(nameof(Error), new { message = "Not encontrado" }));
            }

            List <Department> departments = await _departmentService.FindAllAsync();

            SallerFormViewModel viewmodel = new SallerFormViewModel {
                Seller = obj, Departments = departments
            };

            return(View(viewmodel));
        }