public IEnumerable<PostModel> GetByTags([FromUri]string tags,
[ValueProvider(typeof(HeaderValueProviderFactory<string>))]string sessionKey)
{
if (tags == null)
{
var errorResponse = this.Request.CreateErrorResponse(
HttpStatusCode.BadRequest, "Tags to search are not provided!");
throw new HttpResponseException(errorResponse);
}
var allPostModels = this.GetAll(sessionKey);
var tagsToSearch = tags.Split(TagSeparators, StringSplitOptions.RemoveEmptyEntries);
var postsWithTags = new List<PostModel>();
foreach (var postModel in allPostModels)
{
if (PostContainsAllTags(postModel, tagsToSearch))
{
postsWithTags.Add(postModel);
}
}
return postsWithTags;
}