Skip to content

Commit

Permalink
Add the initial Flight Finder Sample (with stylecop formatting applied).
Browse files Browse the repository at this point in the history
References #27.
  • Loading branch information
jspuij committed Jan 24, 2020
1 parent 4e4af52 commit ecd1993
Show file tree
Hide file tree
Showing 47 changed files with 2,233 additions and 1 deletion.
29 changes: 28 additions & 1 deletion Cortex.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{8F1E2084
build\Weaver.props = build\Weaver.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FlightFinder", "FlightFinder", "{CBB14AD6-8431-47E4-B014-F047B07583B7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Todo", "Todo", "{59F94FD7-B4D5-4CBE-9F55-27FA6537B9E6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlightFinder.Shared", "samples\FlightFinder.Shared\FlightFinder.Shared.csproj", "{BBF20B8B-4208-40CB-BCBB-AF33B5A251CA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlightFinder.Server", "samples\FlightFinder.Server\FlightFinder.Server.csproj", "{FDB5D494-7FE7-400E-82C9-B48F210054A8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlightFinder.Client", "samples\FlightFinder.Client\FlightFinder.Client.csproj", "{69505BBC-EC8F-40AF-A2BD-326C6BF5C1C4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -69,6 +79,18 @@ Global
{A9CA7C47-8A56-4BBC-B943-6BE37D1BAE3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9CA7C47-8A56-4BBC-B943-6BE37D1BAE3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9CA7C47-8A56-4BBC-B943-6BE37D1BAE3F}.Release|Any CPU.Build.0 = Release|Any CPU
{BBF20B8B-4208-40CB-BCBB-AF33B5A251CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBF20B8B-4208-40CB-BCBB-AF33B5A251CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBF20B8B-4208-40CB-BCBB-AF33B5A251CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBF20B8B-4208-40CB-BCBB-AF33B5A251CA}.Release|Any CPU.Build.0 = Release|Any CPU
{FDB5D494-7FE7-400E-82C9-B48F210054A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDB5D494-7FE7-400E-82C9-B48F210054A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDB5D494-7FE7-400E-82C9-B48F210054A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FDB5D494-7FE7-400E-82C9-B48F210054A8}.Release|Any CPU.Build.0 = Release|Any CPU
{69505BBC-EC8F-40AF-A2BD-326C6BF5C1C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69505BBC-EC8F-40AF-A2BD-326C6BF5C1C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69505BBC-EC8F-40AF-A2BD-326C6BF5C1C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69505BBC-EC8F-40AF-A2BD-326C6BF5C1C4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -80,7 +102,12 @@ Global
{062DC911-53C6-4CB0-B4A9-AD6AB98D52BE} = {222F158B-3299-40FA-B8FA-ADF8E611EE54}
{6A213F26-6769-432E-A157-DCEBA92F9E3D} = {3FEECB8E-0064-4CA1-B796-B62EDB6387D5}
{2F1F7856-1D48-4087-B368-31A2CE1206EA} = {222F158B-3299-40FA-B8FA-ADF8E611EE54}
{A9CA7C47-8A56-4BBC-B943-6BE37D1BAE3F} = {79D4183C-B3B6-4ACE-82EF-3D103EB90049}
{A9CA7C47-8A56-4BBC-B943-6BE37D1BAE3F} = {59F94FD7-B4D5-4CBE-9F55-27FA6537B9E6}
{CBB14AD6-8431-47E4-B014-F047B07583B7} = {79D4183C-B3B6-4ACE-82EF-3D103EB90049}
{59F94FD7-B4D5-4CBE-9F55-27FA6537B9E6} = {79D4183C-B3B6-4ACE-82EF-3D103EB90049}
{BBF20B8B-4208-40CB-BCBB-AF33B5A251CA} = {CBB14AD6-8431-47E4-B014-F047B07583B7}
{FDB5D494-7FE7-400E-82C9-B48F210054A8} = {CBB14AD6-8431-47E4-B014-F047B07583B7}
{69505BBC-EC8F-40AF-A2BD-326C6BF5C1C4} = {CBB14AD6-8431-47E4-B014-F047B07583B7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {101D3B0F-E9EE-48BA-BEA0-18A9904B157A}
Expand Down
8 changes: 8 additions & 0 deletions Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

public class Class1
{
public Class1()
{
}
}
51 changes: 51 additions & 0 deletions samples/FlightFinder.Client/Components/AirportsList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// <copyright file="AirportsList.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// these files except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
// </copyright>

namespace FlightFinder.Client.Components
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using FlightFinder.Shared;
using Microsoft.AspNetCore.Components;

/// <summary>
/// A component that displays a list of airpoirts.
/// </summary>
public partial class AirportsList
{
/// <summary>
/// An array of airports.
/// </summary>
private Airport[] airports = Array.Empty<Airport>();

/// <summary>
/// Gets or Sets The Http Client to use.
/// </summary>
[Inject]
public HttpClient Http { get; set; }

/// <summary>
/// Initializes this component. Gets the list of airports from the api.
/// </summary>
/// <returns>The list of airports.</returns>
protected override async Task OnInitializedAsync()
{
this.airports = await this.Http.GetJsonAsync<Airport[]>("api/airports");
}
}
}
6 changes: 6 additions & 0 deletions samples/FlightFinder.Client/Components/AirportsList.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<datalist id="airports">
@foreach (var airport in airports)
{
<option value="@airport.Code">@airport.DisplayName (@airport.Code)</option>
}
</datalist>
37 changes: 37 additions & 0 deletions samples/FlightFinder.Client/Components/GreyOutZone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// <copyright file="GreyOutZone.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// these files except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
// </copyright>

namespace FlightFinder.Client.Components
{
using Microsoft.AspNetCore.Components;

/// <summary>
/// A component that places its child content in a Greyed Out zone.
/// </summary>
public partial class GreyOutZone
{
/// <summary>
/// Gets or sets the Child content for a GreyOutZone.
/// </summary>
[Parameter]
public RenderFragment ChildContent { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the Child content is Greyed Out.
/// </summary>
[Parameter]
public bool IsGreyedOut { get; set; }
}
}
4 changes: 4 additions & 0 deletions samples/FlightFinder.Client/Components/GreyOutZone.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="@(IsGreyedOut ? "greyout" : null)">
<div class="cover"></div>
@ChildContent
</div>
37 changes: 37 additions & 0 deletions samples/FlightFinder.Client/Components/Search.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// <copyright file="Search.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// these files except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
// </copyright>

namespace FlightFinder.Client.Components
{
using FlightFinder.Shared;
using Microsoft.AspNetCore.Components;

/// <summary>
/// Search Component.
/// </summary>
public partial class Search
{
/// <summary>
/// The search criteria that will be returned.
/// </summary>
private readonly SearchCriteria criteria = new SearchCriteria("LHR", "SEA");

/// <summary>
/// Gets or sets the callback that will provide the search criteria for a search.
/// </summary>
[Parameter]
public EventCallback<SearchCriteria> OnSearch { get; set; }
}
}
59 changes: 59 additions & 0 deletions samples/FlightFinder.Client/Components/Search.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<div class="col">
<!-- Airport selection -->
<div class="row py-1">
<!-- From airport -->
<div class="col pr-0">
<div class="form-control d-flex">
<div><i>✈</i>&nbsp;&nbsp;From:</div>
<input list="airports" placeholder="..." @bind="criteria.FromAirport" />
</div>
</div>
<div class="col px-2 py-1 align-self-end arrow">➝</div>

<!-- To airport -->
<div class="col pl-0">
<div class="form-control d-flex">
<div><i>✈</i>&nbsp;&nbsp;To:</div>
<input list="airports" placeholder="..." @bind="criteria.ToAirport" />
</div>
</div>
</div>

<!-- Departure / return dates -->
<div class="row py-1">
<!-- Depart date -->
<div class="col pr-0">
<div class="form-control d-flex">
<div><i>🗓</i>&nbsp;&nbsp;Depart:</div>
<input type="date" @bind="criteria.OutboundDate" @bind:format="yyyy-MM-dd" />
</div>
</div>
<div class="col px-2 py-1 align-self-end arrow">➝</div>

<!-- Return date -->
<div class="col pl-0">
<div class="form-control d-flex">
<div><i>🗓</i>&nbsp;&nbsp;Return:</div>
<input type="date" @bind="criteria.ReturnDate" @bind:format="yyyy-MM-dd" />
</div>
</div>
</div>

<!-- Class / search -->
<div class="row py-1 d-flex px-3">
<div>
<select class="custom-select" @bind="criteria.TicketClass">
<option value=@TicketClass.Economy>Economy</option>
<option value=@TicketClass.PremiumEconomy>Premium Economy</option>
<option value=@TicketClass.Business>Business</option>
<option value=@TicketClass.First>First</option>
</select>
</div>
<div class="ml-auto">
<button @onclick="() => OnSearch.InvokeAsync(criteria)" type="button" class="btn btn-danger px-5">
Search ➝
</button>
</div>
</div>
</div>
<AirportsList />
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// <copyright file="SearchResultFlightSegment.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// these files except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
// </copyright>

namespace FlightFinder.Client.Components
{
using FlightFinder.Shared;
using Microsoft.AspNetCore.Components;

/// <summary>
/// Displays a flight segment of a search result.
/// </summary>
public partial class SearchResultFlightSegment
{
/// <summary>
/// Gets or sets the Symbol.
/// </summary>
[Parameter]
public string Symbol { get; set; }

/// <summary>
/// Gets or sets the flight information.
/// </summary>
[Parameter]
public FlightSegment Flight { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="symbol">
@Symbol
</div>

<div class="airline">
@Flight.Airline
<small>@Flight.TicketClass.ToDisplayString()</small>
</div>

<div class="departure">
<h4>@Flight.DepartureTime.ToShortTimeString()</h4>
@Flight.DepartureTime.ToString("ddd MMM d") (@Flight.FromAirportCode)
</div>

<div class="arrow">➝</div>

<div class="return">
<h4>@Flight.ReturnTime.ToShortTimeString()</h4>
@Flight.ReturnTime.ToString("ddd MMM d") (@Flight.ToAirportCode)
</div>

<div class="duration">
@Flight.DurationHours hours
</div>
70 changes: 70 additions & 0 deletions samples/FlightFinder.Client/Components/SearchResults.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// <copyright file="SearchResults.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// these files except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
// </copyright>

namespace FlightFinder.Client.Components
{
using System.Collections.Generic;
using System.Linq;
using FlightFinder.Shared;
using Microsoft.AspNetCore.Components;

/// <summary>
/// A component that displays a search result.
/// </summary>
public partial class SearchResults
{
/// <summary>
/// The sort order enumeration.
/// </summary>
private enum SortOrder
{
/// <summary>
/// Sort the Itineraries on price.
/// </summary>
Price,

/// <summary>
/// Sort the Itineraries on duration.
/// </summary>
Duration,
}

/// <summary>
/// Gets or sets the Itinerary.
/// </summary>
// Parameters
[Parameter]
public IReadOnlyList<Itinerary> Itineraries { get; set; }

/// <summary>
/// Gets or sets a callback that is called when the Itinerary is added.
/// </summary>
[Parameter]
public EventCallback<Itinerary> OnAddItinerary { get; set; }

/// <summary>
/// Gets or sets the sport order of the Search Results.
/// </summary>
private SortOrder ChosenSortOder { get; set; }

/// <summary>
/// Gets the list of sorted Itineraries.
/// </summary>
private IEnumerable<Itinerary> SortedItineraries
=> this.ChosenSortOder == SortOrder.Price
? this.Itineraries.OrderBy(x => x.Price)
: this.Itineraries.OrderBy(x => x.TotalDurationHours);
}
}
Loading

0 comments on commit ecd1993

Please sign in to comment.