コード例 #1
0
 public IActionResult Search(int page, int itemsPerPage, SearchPostIn postIn)
 {
     return(Ok(new
     {
         success = true,
         reason = "Failed to Search Post, Not Implemented Yet",
     }));
 }
コード例 #2
0
        public bool Search(int page, int itemsPerPage, SearchPostIn postIn, out int pageCount, out ICollection <Post> searched)
        {
            pageCount = 0;
            searched  = null;

            //if (page < 1)
            //{
            //    page = 1;
            //}

            //if (postIn == null)
            //{
            //    return List(page, itemsPerPage, out searched);
            //}

            //// Search Each Property
            //{
            //    searched = null;



            //    // Search by Id
            //    if (string.IsNullOrWhiteSpace(postIn.Id) == false)
            //    {
            //        if (Read(postIn.Id, out Post read) == true)
            //        {
            //            searched.Add(read);
            //        }

            //        return true; // When Search Context, Not Found Post -> Ok
            //    }

            //    // Search by Title
            //    if (string.IsNullOrWhiteSpace(postIn.Title) == false)
            //    {
            //        searched = _posts
            //                    .Find(p => p.Title.Contains(postIn.Title))
            //                    .ToList();

            //        return true;
            //    }

            //    if (string.IsNullOrWhiteSpace(postIn.CreatorId) == false)
            //    {
            //        searched = _posts
            //            .Find(p => p.CreatorId == postIn.CreatorId)
            //            .ToList();

            //        return true;
            //    }

            //    if (string.IsNullOrWhiteSpace(postIn.Text) == false)
            //    {
            //        searched = _posts
            //            .Find(p => p.Text == postIn.Text)
            //            .ToList();

            //        return true;
            //    }

            //    if (postIn.Tags != null && postIn.Tags.Count() > 0)
            //    {
            //        var first = postIn.Tags.First();
            //        searched = _posts
            //            .Find(p => p.Tags.Contains(first))
            //            .ToList();

            //        // @TODO : Multiple Tag Search

            //        return true;
            //    }
            //}

            return(true);
        }