public IActionResult Post([FromBody] PilotDTO pilotDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { pilotService.CreateEntity(pilotDTO); } catch (ValidationException e) { return(BadRequest(new { Exception = e.Message })); } return(Ok(pilotDTO)); }
public void CreateEntity_Should_Create_pilot_in_db() { // Arrange PilotDTO pilotDTO = new PilotDTO { FirstName = "TestName4", LastName = "TestName4", BirthDate = DateTime.Parse("12.06.1994"), Experience = 10 }; // Act _pilotService.CreateEntity(pilotDTO); var pilotResult = dispatcherContext.Pilots .FirstOrDefault(c => c.FirstName == "TestName4" && c.LastName == "TestName4"); // Assert Assert.IsTrue(pilotResult != null); }