public IActionResult GetAllAircrafts() { IEnumerable <Aircraft> aircrafts = _aircraftService.GetAllAircrafts(); if (aircrafts == null) { return(NotFound()); } // Enumerate through each single Aircraft and call CreateLinks method. aircrafts = aircrafts.Select(aircraft => { aircraft = CreateLinks(aircraft); return(aircraft); }); Link link = new Link { Href = Url.Link(nameof(GetAllAircrafts), null), Relation = "self", Method = Link.GetMethod }; var response = new { Value = aircrafts, Links = link }; return(Ok(response)); }
public void TestSetup() { A.CallTo(() => fakeAircraftService.AddAircraft(A <AircraftDTO> ._)).Invokes((AircraftDTO a) => { a.Id = Aircrafts.Count + 1; Aircrafts.Add(a); }); A.CallTo(() => fakeAircraftService.DeleteAircraft(A <int> ._)).Invokes((int id) => Aircrafts.RemoveAll(a => a.Id == id)); A.CallTo(() => fakeAircraftService.UpdateAircraft(A <int> ._, A <AircraftDTO> ._)).Returns(Aircrafts.FirstOrDefault()); A.CallTo(() => fakeAircraftService.GetAircraft(A <int> ._)).Returns(Aircrafts.FirstOrDefault()); A.CallTo(() => fakeAircraftService.GetAllAircrafts()).Returns(Aircrafts); A.CallTo(() => fakeAircraftRepository.Create(A <Aircraft> ._)); A.CallTo(() => fakeAircraftRepository.Update(A <int> ._, A <Aircraft> ._)); A.CallTo(() => fakeAircraftRepository.Delete(A <int> ._)); A.CallTo(() => fakeAircraftRepository.GetById(A <int> ._)); A.CallTo(() => fakeAircraftRepository.GetAll()); A.CallTo(() => fakeUnitOfWork.Aircrafts).Returns(fakeAircraftRepository); }
public async Task <JsonResult> Get() { return(Json(await aircraftService.GetAllAircrafts())); }
public JsonResult Get() { return(Json(aircraftService.GetAllAircrafts())); }