Skip to content

Commit

Permalink
Merge pull request #364 from Sitecore/fix/recommit
Browse files Browse the repository at this point in the history
MVP Changes Recommit
  • Loading branch information
lovesitecore authored Feb 20, 2024
2 parents 0eb07bb + 4a3cf6d commit 9e50dbf
Show file tree
Hide file tree
Showing 22 changed files with 360 additions and 252 deletions.
2 changes: 1 addition & 1 deletion Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PackageReference Update="Sitecore.AspNet.RenderingEngine" Version="$(SitecoreAspNetVersion)" />
<PackageReference Update="Sitecore.AspNet.ExperienceEditor" Version="$(SitecoreAspNetVersion)" />
<PackageReference Update="Okta.AspNetCore" Version="4.4.0" />
<PackageReference Update="Mvp.Selections.Client" Version="4.10.1" />
<PackageReference Update="Mvp.Selections.Client" Version="4.12.1" />
<PackageReference Update="StyleCop.Analyzers" Version="1.1.118" />
<PackageReference Update="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Update="Markdig" Version="0.33.0" />
Expand Down
6 changes: 6 additions & 0 deletions src/Feature/People/rendering/Models/AwardData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Mvp.Feature.People.Models;

public class AwardData
{
public Awards[] TargetItems { get; set; }
}
10 changes: 10 additions & 0 deletions src/Feature/People/rendering/Models/Awards.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Mvp.Foundation.DataFetching.GraphQL.Models;

namespace Mvp.Feature.People.Models;

public class Awards
{
public NameItem Parent { get; set; }

public TargetItemFieldValueItem Field { get; set; }
}
8 changes: 8 additions & 0 deletions src/Feature/People/rendering/Models/CountryData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Mvp.Foundation.DataFetching.GraphQL.Models;

namespace Mvp.Feature.People.Models;

public class CountryData
{
public TargetItem TargetItem { get; set; }
}
8 changes: 8 additions & 0 deletions src/Feature/People/rendering/Models/Facet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Mvp.Feature.People.Models;

public class Facet
{
public string Name { get; set; }
public int Count { get; set; }
public bool Selected { get; set; }
}
170 changes: 0 additions & 170 deletions src/Feature/People/rendering/Models/MvpGraphQLModels.cs

This file was deleted.

6 changes: 6 additions & 0 deletions src/Feature/People/rendering/Models/MvpSearchResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Mvp.Feature.People.Models;

public class MvpSearchResponse
{
public PeopleSearch Search { get; set; }
}
15 changes: 15 additions & 0 deletions src/Feature/People/rendering/Models/MvpSearchResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Mvp.Foundation.DataFetching.GraphQL.Models;

namespace Mvp.Feature.People.Models;

public class MvpSearchResult
{
public string Id { get; set; }
public string Name { get; set; }
public string Path { get; set; }
public ValueItem FirstName { get; set; }
public ValueItem LastName { get; set; }
public ValueItem Email { get; set; }
public CountryData Country { get; set; }
public AwardData Awards { get; set; }
}
10 changes: 10 additions & 0 deletions src/Feature/People/rendering/Models/PeopleSearch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Mvp.Foundation.DataFetching.GraphQL.Models;

namespace Mvp.Feature.People.Models;

public class PeopleSearch
{
public MvpSearchResult[] Results { get; set; }
public int Total { get; set; }
public PageInfo PageInfo { get; set; }
}
84 changes: 84 additions & 0 deletions src/Feature/People/rendering/Models/PeopleSearchResults.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;

namespace Mvp.Feature.People.Models;

public class PeopleSearchResults
{
public IEnumerable<Person> People { get; set; }
public int TotalCount { get; set; }
public int CurrentPage { get; set; }
public int PageSize { get; set; }
public IDictionary<string, List<Facet>> Facets { get; set; }
public bool HasNextPage
{
get
{
return CurrentPage < LastPage;
}
}

public bool HasPreviousPage
{
get
{
return CurrentPage > 1;
}
}

public int LastPage
{
get
{
if (TotalCount == 0 || PageSize == 0)
{
return 1;
}
return (int)Math.Ceiling(((decimal)TotalCount) / ((decimal)PageSize));
}
}

public int PagerStart
{
get
{
if (CurrentPage > 3)
{
return CurrentPage - 2;
}
else
{
return 1;
}
}
}

public int PagerEnd
{
get
{
if (!HasNextPage)
{
return CurrentPage;
}

if (CurrentPage + 2 >= LastPage)
{
return LastPage;
}
if (CurrentPage < 2 && LastPage > 5)
{
return CurrentPage + 4;
}
if (CurrentPage < 3 && LastPage > 5)
{
return CurrentPage + 3;
}
if (CurrentPage < 3 && LastPage <= 5)
{
return LastPage;
}
return CurrentPage + 2;
}
}
}
13 changes: 13 additions & 0 deletions src/Feature/People/rendering/Models/Person.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Mvp.Feature.People.Models
{
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Url { get; set; }
public string Country { get; set; }
public string MvpYear { get; set; }
public string MvpCategory { get; set; }
}
}
21 changes: 21 additions & 0 deletions src/Feature/People/rendering/Models/SearchParams.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Mvc;

namespace Mvp.Feature.People.Models;

public class SearchParams
{
[FromQuery(Name = Constants.QueryParameters.Page)]
public int CurrentPage { get; set; }

[FromQuery(Name = Constants.QueryParameters.Query)]
public string Keyword { get; set; }

[FromQuery(Name = Constants.QueryParameters.FacetAward)]
public string Award { get; set; }

[FromQuery(Name = Constants.QueryParameters.FacetYear)]
public string Year { get; set; }

[FromQuery(Name = Constants.QueryParameters.FacetCountry)]
public string Country { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


<ItemGroup>
<PackageReference Include="Mvp.Selections.Client" />
<PackageReference Include="Sitecore.LayoutService.Client" />
<PackageReference Include="Sitecore.AspNet.RenderingEngine" />
<PackageReference Include="GraphQL.Client" />
Expand Down
Loading

0 comments on commit 9e50dbf

Please sign in to comment.