Search works (#3)
Still need to clean it up a bit, and make the UI have a collapsed section once the search is completed
This commit is contained in:
37
src/JobsJobsJobs/Shared/Api/ProfileSearch.cs
Normal file
37
src/JobsJobsJobs/Shared/Api/ProfileSearch.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
namespace JobsJobsJobs.Shared.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// The various ways profiles can be searched
|
||||
/// </summary>
|
||||
public class ProfileSearch
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieve citizens from this continent
|
||||
/// </summary>
|
||||
public string? ContinentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Text for a search within a citizen's skills
|
||||
/// </summary>
|
||||
public string? Skill { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Text for a search with a citizen's professional biography and experience fields
|
||||
/// </summary>
|
||||
public string? BioExperience { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to retrieve citizens who do or do not want remote work
|
||||
/// </summary>
|
||||
public string RemoteWork { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Is the search empty?
|
||||
/// </summary>
|
||||
public bool IsEmptySearch =>
|
||||
string.IsNullOrEmpty(ContinentId)
|
||||
&& string.IsNullOrEmpty(Skill)
|
||||
&& string.IsNullOrEmpty(BioExperience)
|
||||
&& string.IsNullOrEmpty(RemoteWork);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace JobsJobsJobs.Shared
|
||||
using System;
|
||||
|
||||
namespace JobsJobsJobs.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// A result with two different possibilities
|
||||
@@ -60,5 +62,24 @@
|
||||
/// <param name="error">The error message</param>
|
||||
/// <returns>The Error result</returns>
|
||||
public static Result<TOk> AsError(string error) => new Result<TOk>(false) { Error = error };
|
||||
|
||||
/// <summary>
|
||||
/// Transform a result if it is OK, passing the error along if it is an error
|
||||
/// </summary>
|
||||
/// <param name="f">The transforming function</param>
|
||||
/// <param name="result">The existing result</param>
|
||||
/// <returns>The resultant result</returns>
|
||||
public static Result<TOk> Bind(Func<TOk, Result<TOk>> f, Result<TOk> result) =>
|
||||
result.IsOk ? f(result.Ok) : result;
|
||||
|
||||
/// <summary>
|
||||
/// Transform a result to a different type if it is OK, passing the error along if it is an error
|
||||
/// </summary>
|
||||
/// <typeparam name="TOther">The type to which the result is transformed</typeparam>
|
||||
/// <param name="f">The transforming function</param>
|
||||
/// <param name="result">The existing result</param>
|
||||
/// <returns>The resultant result</returns>
|
||||
public static Result<TOther> Map<TOther>(Func<TOk, Result<TOther>> f, Result<TOk> result) =>
|
||||
result.IsOk ? f(result.Ok) : Result<TOther>.AsError(result.Error);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user