public async Task <Ship> AddShipAsync(Ship ship) { if (ship.Name.Length > 0) { var shipUpload = new ShipUpload(ship.Name, File.ReadAllBytes(ship.Path)); HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync("api/values", shipUpload); if (responseMessage.IsSuccessStatusCode) { ship = await responseMessage.Content.ReadAsAsync <Ship>(); MessageBox.Show(" New Ship\n Name: " + ship.Name); } else { MessageBox.Show("Oops"); } } else { MessageBox.Show("Enter ship name"); } return(ship); }
public IActionResult Post([FromBody] ShipUpload shipUpload) { if (shipUpload != null) { if (_repository.GetShip(shipUpload.Name) == null) { var ship = _repository.Create(shipUpload.Name, shipUpload.ImgByte); return(Ok(ship)); } return(BadRequest()); } return(BadRequest()); }