public async Task <IActionResult> PutPedido(int id, Pedido pedido)
        {
            if (id != pedido.Id)
            {
                return(BadRequest());
            }

            _context.Entry(pedido).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PedidoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        private async Task LiberarDrones(List <DronesPedidosDTO> statusDrone)
        {
            foreach (var drone in statusDrone)
            {
                if (drone.Situacao == "Disponivel")
                {
                    var droneBase = await _context.Drone.FindAsync(drone.DroneId);

                    if (droneBase != null)
                    {
                        if (droneBase.Perfomance != droneBase.PerfomanceRestante)
                        {
                            droneBase.PerfomanceRestante    = droneBase.Perfomance;
                            droneBase.CapacidadeRestante    = droneBase.Capacidade;
                            _context.Entry(droneBase).State = EntityState.Modified;
                            await _context.SaveChangesAsync();
                        }
                    }
                }
            }
        }
Example #3
0
        public void Update(Drone drone)
        {
            _context.Entry(drone).State = Microsoft.EntityFrameworkCore.EntityState.Modified;

            _context.SaveChanges();
        }