BloggingSystem.Services.Controllers.PostsController.GetByTags C# (CSharp) 메소드

GetByTags() 개인적인 메소드

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