public async Task CreateAircraft_WhenAircraftValid_ReturnNewAircraft() { AircraftDto aircraft = new AircraftDto() { AircraftName = "TEST", TypeAircraftId = 1 }; AircraftDto aircraftDtoSaved = await service.Create(aircraft); Assert.AreEqual(aircraft.AircraftName, aircraftDtoSaved.AircraftName); Assert.AreEqual(aircraft.TypeAircraftId, aircraftDtoSaved.TypeAircraftId); bool result = await service.Delete <Aircraft>(aircr => aircr.Id == aircraftDtoSaved.Id); Assert.IsTrue(result); }
public async Task Create_WhenAircraftNull_ThenReturnExeption() { var aircrafts = new IFakeRepository <Aircraft>(); var context = new IFakeUnitOfFactory(); AircraftDto aircraftDto = null; AircraftService service = new AircraftService(context); AircraftDto aircraftDtoSaved = await service.Create(aircraftDto); }
public async Task Create() { Aircraft Aircraft = await AircraftService.Create(this.Aircraft); Aircraft = new Aircraft(); List <Aircraft> tempAircrafts = await AircraftService.GetAll(); Aircrafts = new ObservableCollection <Aircraft>(); foreach (var item in tempAircrafts) { Aircrafts.Add(item); } NotifyPropertyChanged(() => Aircrafts); }
public async Task Create_WhenValidAircraft_ThenReturnAircraft() { var aircrafts = new IFakeRepository <Aircraft>(); var context = new IFakeUnitOfFactory(); AircraftDto aircraftDto = new AircraftDto() { Id = 154, AircraftName = "Test", TypeAircraftId = 165 }; AircraftService service = new AircraftService(context); AircraftDto aircraftDtoSaved = await service.Create(aircraftDto); Assert.AreEqual(aircraftDto.AircraftName, aircraftDtoSaved.AircraftName); Assert.AreEqual(aircraftDto.Id, aircraftDtoSaved.Id); Assert.AreEqual(aircraftDto.TypeAircraftId, aircraftDtoSaved.TypeAircraftId); }
public IActionResult Save(SaveAircraftModel model) { if (model.AircraftId.HasValue) { _aircraftService.Update(model.AircraftId.Value, model.TailNumber, model.TypeId, model.ModelId, model.HomebaseId, model.ArgusSafetyRating, model.WyvernSafetyRating, model.ManufactureYear, model.LastIntRefurbish, model.LastExtRefurbish, model.MaxPassengers, model.HoursFlown, model.Speed, model.Range, model.WiFi, model.BookableDemo, model.NumberOfTelevision, model.CargoCapability, model.SellAsCharterAircraft, model.SellAsCharterSeat, model.PricePerHour, model.Images, model.Documents); } else { _aircraftService.Create(model.TailNumber, model.TypeId, model.ModelId, model.HomebaseId, model.ArgusSafetyRating, model.WyvernSafetyRating, model.ManufactureYear, model.LastIntRefurbish, model.LastExtRefurbish, model.MaxPassengers, model.HoursFlown, model.Speed, model.Range, model.WiFi, model.BookableDemo, model.NumberOfTelevision, model.CargoCapability, model.SellAsCharterAircraft, model.SellAsCharterSeat, model.PricePerHour, model.Images, model.Documents); } return(Ok()); }