Last active
April 19, 2018 11:01
-
-
Save ChadRoberts21/e810366d69eff3fe048b6f47109de359 to your computer and use it in GitHub Desktop.
Api - QueryMultiple - abstract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IQueryMultiple | |
{ | |
bool Descending { get; } | |
bool HasQuery { get; } | |
bool HasSearch { get; } | |
string OrderBy { get; set; } | |
int Page { get; set; } | |
int PageCount { get; set; } | |
string Search { get; set; } | |
} | |
public abstract class QueryMultipleAbstact : IQueryMultiple | |
{ | |
private const int maxPageCount = 50; | |
public virtual int Page { get; set; } | |
private int _pageCount = 50; | |
public virtual int PageCount | |
{ | |
get { return _pageCount; } | |
set { _pageCount = (value > maxPageCount) ? maxPageCount : value; } | |
} | |
public virtual bool HasSearch { get { return !String.IsNullOrEmpty(Search); } } | |
public virtual string Search { get; set; } | |
public virtual string OrderBy { get; set; } = "Name"; | |
public virtual bool Descending | |
{ | |
get | |
{ | |
if (!String.IsNullOrEmpty(OrderBy)) | |
{ | |
return OrderBy.Split(' ').Last().ToLowerInvariant().StartsWith("desc"); | |
} | |
return false; | |
} | |
} | |
public virtual bool HasQuery | |
{ | |
get | |
{ | |
bool answer = false; | |
if (Page != 0 ) | |
{ | |
answer = true; | |
} | |
else if (_pageCount > 50) | |
{ | |
answer = true; | |
} | |
else if (!String.IsNullOrEmpty(Search)) | |
{ | |
answer = true; | |
} | |
return answer; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment