Skip to content

Commit

Permalink
Add private ctor for QueryOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
imaun committed Jan 23, 2023
1 parent 25c94d1 commit b5b0e4f
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/Models/QueryOptions.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
namespace Behlog.Core.Models;

/// <summary>
/// Base class for Query filter data classes. Can be used to filter query results.
/// Base class for Query filter data classes. Can be used to filter query results
/// and apply pagingations to the result.
/// </summary>
public class QueryOptions
{
private QueryOptions()
{
}

public int PageNumber { get; set; } = 1;
public int PageSize { get; set; } = 10;
public int StartIndex => (PageNumber * PageSize) - PageSize;
public string OrderBy { get; set; }
public bool OrderDesc { get; set; }
public string? Search { get; set; }

public static QueryOptions New()
{
Expand All @@ -27,5 +33,22 @@ public QueryOptions WithPageSize(int pageSize)
PageSize = pageSize;
return this;
}


public QueryOptions WillOrderBy(string orderBy)
{
OrderBy = orderBy;
return this;
}

public QueryOptions WillOrderDesc()
{
OrderDesc = true;
return this;
}

public QueryOptions SearchingFor(string search)
{
Search = search;
return this;
}
}

0 comments on commit b5b0e4f

Please sign in to comment.