public void TestDroneMap() { var drone = new Drone(new CoordinateInt2D() { X = 1, Y = 1 }) { Name = "Drone_1", Speed = 1, StorageSize = 10 }; var droneDtoExpected = new DroneDto() { Name = "Drone_1", CurrentPosition = new CoordinateInt2D() { X = 1, Y = 1 }, LastInstruction = null, State = DroneState.WaitingForOrders, Speed = 1, StorageSize = 10, Storage = null }; var mapper = new PlayerContextMapper(); var droneDtoActual = mapper.Map(drone); droneDtoActual.Should().BeEquivalentTo(droneDtoExpected); }
public async Task CreateAsync(DroneDto droneDto) { var drone = _mapper.Map <DAL.Entities.Drone>(droneDto); drone.Id = Guid.NewGuid(); await _repository.CreateAsync(drone); }
public HttpResponseMessage getDrones() { var drones = db.drones.ToList().Select(d => DroneDto.CreateFromEntity(d)); HttpResponseMessage res = Request.CreateResponse(HttpStatusCode.OK, drones); return(res); }
public void DroneDtoConstructorTests() { var drone = SetupTests.GetDrone(); var droneDto = new DroneDto(SetupTests.GetDroneStatusDto(), 10); Assert.True( droneDto.Distancia == 10 && droneDto.DroneStatus.SomaDistancia == 5 && droneDto.DroneStatus.SomaPeso == 10); }
public async Task UpdateAsync(DroneDto droneDto) { var drone = await _repository.GetAsync(droneDto.Id); if (drone == null) { throw new GreenFieldNotFoundException(); } if (drone.OrganisationId != droneDto.OrganisationId) { throw new GreenFieldException("forbidden", "You are not allowed to modify this."); } drone = _mapper.Map <DAL.Entities.Drone>(droneDto); await _repository.UpdateAsync(drone); }
private async Task AdicionarPedidoDrone(Pedido pedido, DroneDto drone) { var newDrone = await _droneRepository.GetByIdAsync(drone.DroneStatus.Drone.Id); var newPedido = await _pedidoRepository.GetByIdAsync(pedido.Id); var pedidoDrone = new PedidoDrone() { Distancia = drone.Distancia, Drone = newDrone, DroneId = drone.DroneStatus.Drone.Id, Pedido = newPedido, PedidoId = pedido.Id, StatusEnvio = (int)StatusEnvio.AGUARDANDO }; await _pedidoDroneRepository.AddAsync(pedidoDrone); }