BloggingSystem.Services.Controllers.PostsController.GetByTags C# (CSharp) Method

GetByTags() private method

private GetByTags ( [ tags, [ sessionKey ) : IEnumerable
tags [
sessionKey [
return IEnumerable
        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;
        }