|
using Application.Core.ProfileModule.ProfileAggregate;
using Application.Core.Specification;
using Application.Core.Specification.Implementation;
namespace Application.Core.ProfileModule.ProfileAddressAggregate
{
/// <summary>
/// A list of Profile specification
/// </summary>
public static class ProfileSpecification
{
/// <summary>
/// Profile with firstName or LastName or Email equal to
/// </summary>
/// <param name="firstName"></param>
/// <param name="lastName"></param>
/// <param name="email"></param>
/// <returns>Associated specification for this creterion</returns>
public static Specification<Profile> GetProfileByFilter(string firstName, string lastName, string email)
{
Specification<Profile> specProfile = new TrueSpecification<Profile>();
if ( !string.IsNullOrEmpty(firstName))
specProfile &= new DirectSpecification<Profile>(p => p.FirstName.Contains(firstName));
if (!string.IsNullOrEmpty(lastName))
specProfile &= new DirectSpecification<Profile>(p => p.LastName.Contains(lastName));
if (!string.IsNullOrEmpty(email))
specProfile &= new DirectSpecification<Profile>(p => p.Email.Contains(email));
return specProfile;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.