public async Task <IActionResult> Edit(int id, [Bind("OrdemCarregamentoId,EmpresaId,MotoristaId,Valor,Medida,DataOrdemCarregamento,Destino,TipoCarga,Ativo")] OrdemCarregamento ordemCarregamento)
        {
            if (id != ordemCarregamento.OrdemCarregamentoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ordemCarregamento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrdemCarregamentoExists(ordemCarregamento.OrdemCarregamentoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmpresaId"]   = new SelectList(_context.Empresa, "EmpresaId", "CidadeEmpresa", ordemCarregamento.EmpresaId);
            ViewData["MotoristaId"] = new SelectList(_context.Motorista, "MotoristaId", "CaminhaoProprietario", ordemCarregamento.MotoristaId);
            return(View(ordemCarregamento));
        }
        public async Task <IActionResult> Create([Bind("OrdemCarregamentoId,EmpresaId,MotoristaId,Valor,Medida,DataOrdemCarregamento,Destino,TipoCarga,Ativo")] OrdemCarregamento ordemCarregamento)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ordemCarregamento);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmpresaId"]   = new SelectList(_context.Empresa, "EmpresaId", "CidadeEmpresa", ordemCarregamento.EmpresaId);
            ViewData["MotoristaId"] = new SelectList(_context.Motorista, "MotoristaId", "CaminhaoProprietario", ordemCarregamento.MotoristaId);
            return(View(ordemCarregamento));
        }