Exemplo n.º 1
0
        public IActionResult Search(string searchFilter)
        {
            if (!String.IsNullOrEmpty(searchFilter))
            {
                var posts = _postService.GetPostsBySearchFilter(searchFilter);

                if (posts.Count > 0)
                {
                    var model = new PostSearchViewModel
                    {
                        Posts = posts
                    };

                    return(View(model));
                }

                else
                {
                    TempData["Message"]      = "Aradığınız kelimeye uygun sonuç bulunamadı !";
                    TempData["MessageState"] = "warning";
                    return(RedirectToAction("Index", "Post"));
                }
            }

            TempData["Message"]      = "Arama filtresi boş olmamalıdır !";
            TempData["MessageState"] = "danger";
            return(RedirectToAction("Index", "Post"));
        }
Exemplo n.º 2
0
        public IActionResult List()
        {
            var model = new PostSearchViewModel();

            PreparingPostSearchModel(model);
            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> ListData(PostSearchViewModel model)
        {
            model.LanguageFID = model.LanguageFID == 0 ? LanguageConstant.DEFAULT_LANGUAGE_ID : model.LanguageFID;
            var posts = await _postService.SearchPost(model);

            await PreparingSearchResult(posts.ResponseData);

            return(PartialView("_PostListTable", posts.ResponseData));
        }
Exemplo n.º 4
0
 public static PostSearchDto ToDto(this PostSearchViewModel source)
 {
     return(new PostSearchDto
     {
         PageNumber = source.PageNumber,
         PageSize = source.PageSize,
         Title = source.Title
     });
 }
Exemplo n.º 5
0
        public JsonResult Search(PostSearchViewModel model)
        {
            Response response;

            try
            {
                List <PostItem> list;
                int             dataCount;
                using (var db = new KiaGalleryContext())
                {
                    var query = db.PostItem.Include(x => x.City).Select(x => x);

                    if (!string.IsNullOrEmpty(model.term?.Trim()))
                    {
                        query = query.Where(x => x.TrackingCode.Contains(model.term.Trim()) || x.InvoiceNo.Contains(model.term.Trim()) || x.Customer.Contains(model.term.Trim()) || x.Customer.Contains(model.term.Trim().Replace("ی", "ي").Replace("ک", "ك")) || x.PhoneNumber.Contains(model.term.Trim()) || x.MobileNumber.Contains(model.term.Trim()) || x.Address.Contains(model.term.Trim()) || x.Address.Contains(model.term.Trim().Replace("ی", "ي").Replace("ک", "ك")) || x.PostalCode.Contains(model.term.Trim()));
                    }

                    dataCount = query.Count();
                    query     = query.OrderByDescending(x => x.Id).Skip(model.page * model.count).Take(model.count);

                    list = query.ToList();
                }

                response = new Response()
                {
                    status = 200,

                    data = new
                    {
                        list = list.Select(item => new
                        {
                            id           = item.Id,
                            cityName     = item.City.Name,
                            invoiceNo    = item.InvoiceNo,
                            count        = item.Count,
                            weight       = item.Weight,
                            customer     = item.Customer,
                            submitUser   = item.SubmitUser,
                            submitDate   = DateUtility.GetPersianDate(item.SubmitDate),
                            postDate     = DateUtility.GetPersianDate(item.PostDate),
                            trackingCode = item.TrackingCode
                        }),
                        pageCount = Math.Ceiling((double)dataCount / model.count),
                        count     = dataCount,
                        page      = model.page + 1
                    }
                };
            }
            catch (Exception ex)
            {
                response = Core.GetExceptionResponse(ex);
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
 public IActionResult Blog(PostSearchViewModel post)
 {
     if (!string.IsNullOrEmpty(post.Text))
     {
         post.Blog = _postRepository.GetPostByName(post.Text);
     }
     else
     {
         post.Blog = _postRepository.GetAllIQPosts();
     }
     return(View(post));
 }
Exemplo n.º 7
0
        public IActionResult Blog()
        {
            ViewBag.Message = "Form submitted.";

            ViewBag.Title = "Blog";
            PostSearchViewModel post = new PostSearchViewModel()
            {
                Blog = _postRepository.GetAllIQPosts(),
                Text = ""
            };

            return(View(post));
        }
Exemplo n.º 8
0
        public IActionResult Index(PostSearchViewModel searchModel)
        {
            var data = _adminService.GetPosts(searchModel.ToDto());

            List <SelectListItem> pageSizeSelector = new List <SelectListItem>();

            pageSizeSelector.Add(new SelectListItem("10", "10", searchModel.PageSize == 10));
            pageSizeSelector.Add(new SelectListItem("20", "20", searchModel.PageSize == 20));
            pageSizeSelector.Add(new SelectListItem("30", "30", searchModel.PageSize == 30));
            pageSizeSelector.Add(new SelectListItem("40", "40", searchModel.PageSize == 40));
            pageSizeSelector.Add(new SelectListItem("50", "50", searchModel.PageSize == 50));

            ViewBag.PageSizeSelector = pageSizeSelector;

            return(View(new SearchModel <PostSearchViewModel, PaginationViewModel <PostViewModel> >(searchModel, data.ToVewModel())));
        }
Exemplo n.º 9
0
        public IActionResult Index(PostSearchViewModel model)
        {
            if (model.PageIndex == 0)
            {
                model.PageIndex = 1;
            }
            if (model.PageSize == 0)
            {
                model.PageSize = 10;
            }

            ViewBag.SearchKey = model.SearchKey;

            var data = _post.GetPostList();

            if (!string.IsNullOrEmpty(model.SearchKey))
            {
                data = data.FindAll(o => o.Content.Contains(model.SearchKey) || o.Title.Contains(model.SearchKey));
            }

            IPagedList <Post> posts = data.OrderByDescending(o => o.DateCreated).ToList().ToPagedList(model.PageIndex, model.PageSize);
            // map to IEnumerable
            IEnumerable <PostListViewModel> postList = _mapper.Map <IEnumerable <PostListViewModel> >(posts);
            // create an instance of StaticPagedList with the mapped IEnumerable and original IPagedList metadata
            IPagedList <PostListViewModel> postListViewModel = new StaticPagedList <PostListViewModel>(postList, posts.GetMetaData());

            foreach (var item in postListViewModel)
            {
                item.UserName     = _userManager.FindByIdAsync(item.UserId).Result.UserName;
                item.CategoryName = _category.GetCategory(o => o.CategoryId == item.CategoryId).CategoryName;
                item.PostTagList  = _mapper.Map <List <PostTag>, List <PostTagViewModel> >(_postTag.GetPostTagList(o => o.PostId == item.PostId));
                foreach (var postTag in item.PostTagList)
                {
                    postTag.TagName = _tag.GetTag(o => o.TagId == postTag.TagId).TagName;
                }
            }

            var postInfoModel = new PostInfoViewModel
            {
                PostList     = postListViewModel,
                TagList      = _mapper.Map <List <Tag>, List <TagViewModel> >(_tag.GetTagList()),
                CategoryList = _mapper.Map <List <Category>, List <CategoryViewModel> >(_category.GetCategoryList())
            };

            return(View(postInfoModel));
        }
Exemplo n.º 10
0
        public IActionResult Index(string id, PostSearchViewModel model)
        {
            if (model.PageIndex == 0)
            {
                model.PageIndex = 1;
            }
            if (model.PageSize == 0)
            {
                model.PageSize = 10;
            }

            IPagedList <Post> posts = _post.GetPostList(o => o.UserId == id).OrderByDescending(o => o.DateCreated).ToList().ToPagedList(model.PageIndex, model.PageSize);;

            IEnumerable <PostListViewModel> postList = _mapper.Map <IEnumerable <PostListViewModel> >(posts);
            // create an instance of StaticPagedList with the mapped IEnumerable and original IPagedList metadata
            IPagedList <PostListViewModel> postListViewModel = new StaticPagedList <PostListViewModel>(postList, posts.GetMetaData());

            foreach (var item in postListViewModel)
            {
                item.PostTagList = _mapper.Map <List <PostTag>, List <PostTagViewModel> >(_postTag.GetPostTagList(o => o.PostId == item.PostId));
                foreach (var postTag in item.PostTagList)
                {
                    postTag.TagName = _tag.GetTag(o => o.TagId == postTag.TagId).TagName;
                }
                item.CategoryName = _category.GetCategory(o => o.CategoryId == item.CategoryId).CategoryName;
            }

            var authorModel = new PostAuthorViewModel {
                PostList = postListViewModel
            };

            authorModel.UserName = _userManager.FindByIdAsync(id).Result.UserName;

            authorModel.CountUserPosts = _post.GetCountUserPosts(id);
            authorModel.CountUserViews = _post.GetCountUserViews(id).Value;

            return(View(authorModel));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Index(string searchByType, string searchString)
        {
            var model = new PostSearchViewModel();

            if (!string.IsNullOrEmpty(searchString) && !string.IsNullOrEmpty(searchByType))
            {
                if (searchByType == "Name")
                {
                    model.Posts = await postService.GetByName(searchString);
                }

                else if (searchByType == "Content")
                {
                    model.Posts = await postService.GetByPartialContent(searchString);
                }

                else
                {
                    return(BadRequest($"Search type {searchByType} not found."));
                }
            }

            return(View(model));
        }
Exemplo n.º 12
0
 private void PreparingPostSearchModel(PostSearchViewModel model)
 {
     model.Categories = _selectListService.PreparingCategoryList();
 }