public async Task <IActionResult> Get([FromQuery] CategorySearchModel searchmodel)
        {
            const string loggerHeader = "GetCategorys -";

            _logService.Info($"{loggerHeader} Start");
            var result = new ApiJsonResult();

            try
            {
                if (searchmodel.TypeSearch == (int)TypeSearchCategory.ByMenuCategory)
                {
                    result.Data = await _CategoryService.GetMenuCategory();
                }
                if (searchmodel.TypeSearch == (int)TypeSearchCategory.ByGetOneId)
                {
                    result.Data = await _CategoryService.GetOneId(searchmodel.CategoryID);
                }
            }
            catch (Exception ex)
            {
                _logService.Error($"{loggerHeader} Throw error {ex.Message}");
                result.Code    = CodeModel.Fail;
                result.Message = ex.Message;
            }

            return(Ok(result));
        }
        public IActionResult ListData(CategorySearchModel searchModel)
        {
            if (!_permissionService.Authorize(UserManualPermissionProvider.ManageUserManuals))
            {
                return(AccessDeniedView());
            }

            var manufacturerDict = _manufacturerService.GetAllManufacturers(showHidden: true).ToDictionary(x => x.Id, x => x);
            var categoryDict     = _userManualService.GetOrderedCategories(showUnpublished: true).ToDictionary(x => x.Id, x => x);

            var userManuals = _userManualService.GetOrderedUserManuals(showUnpublished: true, searchModel.Page - 1, searchModel.PageSize);
            var model       = new UserManualListModel().PrepareToGrid(searchModel, userManuals, () =>
            {
                return(userManuals.Select(userManual =>
                {
                    var um = userManual.ToModel();

                    um.CategoryName = categoryDict.ContainsKey(um.CategoryId) ? categoryDict[um.CategoryId].Name : "";
                    um.CategoryPublished = categoryDict.ContainsKey(um.CategoryId) && categoryDict[um.CategoryId].Published;

                    um.ManufacturerName = manufacturerDict.ContainsKey(um.ManufacturerId) ? manufacturerDict[um.ManufacturerId].Name : "";
                    um.ManufacturerPublished = manufacturerDict.ContainsKey(um.ManufacturerId) && manufacturerDict[um.ManufacturerId].Published;

                    return um;
                }));
            });

            return(Json(model));
        }
        public List <CategoryModel> FilterSearch([FromBody] CategorySearchModel model)
        {
            List <CategoryModel> models = new List <CategoryModel>();
            var list = _categoryAssigment.GetList();

            foreach (var item in list)
            {
                CategoryModel categoryModel = new CategoryModel();
                if (model.CategoryIds.Count(x => x.Equals(item.CategoryId)) > 0 || model.AuthorIds.Count(y => y.Equals(item.AuthorId)) > 0 || model.PublisherId == item.PublisherId)
                {
                    if (models.Count == 0)
                    {
                        categoryModel.Id   = item.CategoryId;
                        categoryModel.Name = item.CategoryName;

                        MongoBookModel book = new MongoBookModel();
                        book.AuthorId      = item.AuthorId;
                        book.AuthorName    = item.AuthorName;
                        book.AuthorSurname = item.AuthorSurname;
                        book.BookName      = item.BookName;
                        book.BookId        = item.BookId;
                        book.SignUrl       = item.SignUrl;

                        //gelen filtreye göre category ve onun kitaplarını listele sorun şu ki hangi kategorinin kitaplarının hangi sırayla geleceğni bilmiyoruz.
                        //    düzenlemek gerekiyor.
                    }
                    else
                    {
                    }
                }
            }
            return(null);
        }
        /// <summary>
        /// Prepare category search model
        /// </summary>
        /// <param name="searchModel">Category search model</param>
        /// <returns>Category search model</returns>
        public virtual CategorySearchModel PrepareCategorySearchModel(CategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare available stores
            _baseAdminModelFactory.PrepareStores(searchModel.AvailableStores);

            searchModel.HideStoresList = _catalogSettings.IgnoreStoreLimitations || searchModel.AvailableStores.SelectionIsNotPossible();

            //prepare "published" filter (0 - all; 1 - published only; 2 - unpublished only)
            searchModel.AvailablePublishedOptions.Add(new SelectListItem
            {
                Value = "0",
                Text  = _localizationService.GetResource("Admin.Catalog.Categories.List.SearchPublished.All")
            });
            searchModel.AvailablePublishedOptions.Add(new SelectListItem
            {
                Value = "1",
                Text  = _localizationService.GetResource("Admin.Catalog.Categories.List.SearchPublished.PublishedOnly")
            });
            searchModel.AvailablePublishedOptions.Add(new SelectListItem
            {
                Value = "2",
                Text  = _localizationService.GetResource("Admin.Catalog.Categories.List.SearchPublished.UnpublishedOnly")
            });

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
        /// <summary>
        /// Prepare paged category list model
        /// </summary>
        /// <param name="searchModel">Category search model</param>
        /// <returns>Category list model</returns>
        public virtual CategoryListModel PrepareCategoryListModel(CategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }
            //get categories
            var categories = _categoryService.GetAllCategories(categoryName: searchModel.SearchCategoryName,
                                                               showHidden: true,
                                                               storeId: searchModel.SearchStoreId,
                                                               pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize,
                                                               overridePublished: searchModel.SearchPublishedId == 0 ? null : (bool?)(searchModel.SearchPublishedId == 1));

            //prepare grid model
            var model = new CategoryListModel().PrepareToGrid(searchModel, categories, () =>
            {
                return(categories.Select(category =>
                {
                    //fill in model values from the entity
                    var categoryModel = category.ToModel <CategoryModel>();

                    //fill in additional values (not existing in the entity)
                    categoryModel.Breadcrumb = _categoryService.GetFormattedBreadCrumb(category);
                    categoryModel.SeName = _urlRecordService.GetSeName(category, 0, true, false);

                    return categoryModel;
                }));
            });

            return(model);
        }
        /// <summary>
        /// Prepare paged category list model
        /// </summary>
        /// <param name="searchModel">Category search model</param>
        /// <returns>Category list model</returns>
        public virtual CategoryListModel PrepareCategoryListModel(CategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get categories
            var categories = _categoryService.GetAllCategories(categoryName: searchModel.SearchCategoryName,
                                                               showHidden: true,
                                                               pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize);

            //prepare grid model
            var model = new CategoryListModel().PrepareToGrid(searchModel, categories, () =>
            {
                return(categories.Select(category =>
                {
                    //fill in model values from the entity
                    var categoryModel = category.ToModel <CategoryModel>();

                    //fill in additional values (not existing in the entity)
                    var defaultCategoryPicture = _pictureService.GetPictureById(category.PictureId);
                    categoryModel.PictureThumbnailUrl = _pictureService.GetPictureUrl(defaultCategoryPicture, 75);
                    categoryModel.Breadcrumb = _categoryService.GetFormattedBreadCrumb(category);
                    categoryModel.TotalQuestions = _categoryService.GetCategoryQuestionsCount(category, showHidden: true);
                    categoryModel.PublishedQuestions = _categoryService.GetCategoryQuestionsCount(category, showHidden: false);
                    return categoryModel;
                }));
            });

            return(model);
        }
        /// <summary>
        /// Prepare paged category list model
        /// </summary>
        /// <param name="searchModel">Category search model</param>
        /// <returns>Category list model</returns>
        public virtual CategoryListModel PrepareCategoryListModel(CategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get categories
            var categories = _categoryService.GetAllCategories(categoryName: searchModel.SearchCategoryName,
                                                               showHidden: true,
                                                               storeId: searchModel.SearchStoreId,
                                                               pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize);

            //prepare grid model
            var model = new CategoryListModel
            {
                Data = categories.Select(category =>
                {
                    //fill in model values from the entity
                    var categoryModel = category.ToModel <CategoryModel>();

                    //fill in additional values (not existing in the entity)
                    categoryModel.Breadcrumb = _categoryService.GetFormattedBreadCrumb(category);

                    return(categoryModel);
                }),
                Total = categories.TotalCount
            };

            return(model);
        }
        public ActionResult CategorySearch(int?page, CategorySearchModel Model)
        {
            Model.searchResultModel   = new List <CategoryViewModel>();
            Model.searchResultModel   = _categoryBL.Search(Model);
            Session[ScreenController] = Model;
            var pageNumber = (page ?? 1);
            var list       = Model.searchResultModel.ToPagedList(pageNumber, 100);

            return(PartialView("ListCategory", list));
        }
        /// <summary>
        /// Prepare category search model
        /// </summary>
        /// <param name="searchModel">Category search model</param>
        /// <returns>Category search model</returns>
        public virtual CategorySearchModel PrepareCategorySearchModel(CategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }
            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
 public IHttpActionResult GetCategorys(CategorySearchModel model)
 {
     try
     {
         return(Ok(GetDataList(model)));
     }
     catch (Exception ex)
     {
         return(ResponseMessage(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)));
     }
 }
        public IActionResult List()
        {
            if (!_permissionService.Authorize(UserManualPermissionProvider.ManageUserManuals))
            {
                return(AccessDeniedView());
            }

            var model = new CategorySearchModel();

            model.SetGridPageSize();
            return(View($"{Route}{nameof(List)}.cshtml", model));
        }
        public virtual async Task <IActionResult> List(CategorySearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCategories))
            {
                return(await AccessDeniedDataTablesJson());
            }

            //prepare model
            var model = await _categoryModelFactory.PrepareCategoryListModelAsync(searchModel);

            return(Json(model));
        }
        public virtual IActionResult List(CategorySearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedKendoGridJson());
            }

            //prepare model
            var model = _categoryModelFactory.PrepareCategoryListModel(searchModel);

            return(Json(model));
        }
 public ActionResult ManageProjectCategory(CategorySearchModel cm)
 {
     try
     {
         var page = cm.Page ?? 1;
         cm.SearchResults = Repository.GetAllCategoriesByPageSize(page, RecordsPerPage);
         return(View(cm));
     }
     catch
     {
         return(View("Error"));
     }
 }
Exemple #15
0
        public virtual IActionResult List(CategorySearchModel searchModel)
        {
            bool isAuthorized = _authorizationService.AuthorizeAsync(User, GetCurrentUserAsync(), CustomerOperations.Read).Result.Succeeded;

            if (!isAuthorized)
            {
                return(AccessDeniedView());
            }
            //prepare model
            CategoryListModel model = _categoryModelFactory.PrepareCategoryListModel(searchModel);

            return(Json(model));
        }
        protected IEnumerable <Product> GetProductFromHtml(string html, CategorySearchModel searchModel)
        {
            var output       = new List <Product>();
            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(html);
            var nodes = htmlDocument.DocumentNode.GetNodesFromIdentifier(searchModel.ProductItemIdentifier);//("//*[@class='" + classValue + "']");

            foreach (var node in nodes)
            {
                output.Add(node.GetEntity(searchModel));
            }

            return(output);
        }
        /// <summary>
        /// Prepare category search model
        /// </summary>
        /// <param name="searchModel">Category search model</param>
        /// <returns>Category search model</returns>
        public virtual CategorySearchModel PrepareCategorySearchModel(CategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare available stores
            _baseAdminModelFactory.PrepareStores(searchModel.AvailableStores);

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
        public ActionResult CategorySearch()
        {
            CategorySearchModel Model = new CategorySearchModel();

            if (Session[ScreenController] != null)
            {
                Model = (CategorySearchModel)Session[ScreenController];
                Model.searchResultModel = new List <CategoryViewModel>();
                Model.searchResultModel = _categoryBL.Search(Model).ToPagedList(1, 100);
            }
            else
            {
                Model.searchResultModel = new List <CategoryViewModel>().ToPagedList(1, 100);
            }
            return(View(Model));
        }
Exemple #19
0
        public virtual IActionResult List()
        {
            //var userId = GetCurrentUserAsync().Id; //_userManager.GetUserId(User);
            //var customer = _customerService.GetCustomerByAppId(userId);
            bool isAuthorized = _authorizationService.AuthorizeAsync(User, GetCurrentUserAsync(), CustomerOperations.Read).Result.Succeeded;

            if (!isAuthorized)
            {
                return(AccessDeniedView());
            }

            //prepare model
            CategorySearchModel model = _categoryModelFactory.PrepareCategorySearchModel(new CategorySearchModel());

            return(View(model));
        }
        /// <summary>
        /// Prepare category search model
        /// </summary>
        /// <param name="searchModel">Category search model</param>
        /// <returns>Category search model</returns>
        public virtual CategorySearchModel PrepareCategorySearchModel(CategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare available stores
            _baseAdminModelFactory.PrepareStores(searchModel.AvailableStores);

            searchModel.HideStoresList = _catalogSettings.IgnoreStoreLimitations || searchModel.AvailableStores.SelectionIsNotPossible();

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
        private IQueryable <CategoryDto> GetCategories(CategorySearchModel searchModel = null)
        {
            IQueryable <CategoryDto> list = null;

            if (searchModel.IsNull())
            {
                list = _categoryService.GetAll();
            }
            else
            {
                var predicate      = PredicateBuilder.True <CategoryDto>();
                var hasOtherFilter = false;

                if (!searchModel.CategoryCode.IsNull())
                {
                    hasOtherFilter = true;
                    predicate      = predicate.And(a => a.CategoryCode.Contains(searchModel.CategoryCode));
                }

                if (!searchModel.CategoryName.IsNull())
                {
                    hasOtherFilter = true;
                    predicate      = predicate.And(a => a.CategoryName.Contains(searchModel.CategoryName));
                }

                if (!searchModel.isActive.IsNull())
                {
                    hasOtherFilter = true;
                    if (searchModel.isActive == "true")
                    {
                        predicate = predicate.And(a => a.IsActive);
                    }
                    else
                    {
                        predicate = predicate.And(a => !a.IsActive);
                    }
                }



                list = _categoryService.GetAll().AsExpandable().Where(predicate);
            }

            return(list);
        }
Exemple #22
0
        //Find data with condition
        public List <CategoryViewModel> Search(CategorySearchModel model)
        {
            string strQuery = "SELECT cate.`id`, cate_parent.`name` parent_name, cate.`code`, cate.`name`, cate.`description`";

            strQuery += " FROM `product_category` cate LEFT JOIN (SELECT `id`, `name` FROM `product_category`) cate_parent";
            strQuery += " ON cate.`parent_id` = cate_parent.id WHERE 1";
            if (!string.IsNullOrEmpty(model.code) || !string.IsNullOrEmpty(model.name))
            {
                strQuery += (!string.IsNullOrEmpty(model.code)) ? " AND cate.`code` LIKE @code" : "";
                strQuery += (!string.IsNullOrEmpty(model.name)) ? " AND cate.`name` LIKE @name" : "";
                strQuery += " OR cate.`parent_id` IN (SELECT `id` FROM product_category WHERE 1";
                strQuery += (!string.IsNullOrEmpty(model.code)) ? " AND `code` LIKE @code" : "";
                strQuery += (!string.IsNullOrEmpty(model.name)) ? " AND `name` LIKE @name" : "";
                strQuery += ")";
            }
            var result = _db.Query <CategoryViewModel>(strQuery, new { code = '%' + model.code + '%', name = '%' + model.name + '%' }).ToList();

            return(result);
        }
        public IActionResult ListData(CategorySearchModel searchModel)
        {
            if (!_permissionService.Authorize(UserManualPermissionProvider.ManageUserManuals))
            {
                return(AccessDeniedView());
            }

            var categories = _userManualService.GetOrderedCategories(showUnpublished: true, searchModel.Page - 1, searchModel.PageSize);
            var model      = new CategoryListModel().PrepareToGrid(searchModel, categories, () =>
            {
                return(categories.Select(category =>
                {
                    var d = category.ToModel();
                    return d;
                }));
            });

            return(Json(model));
        }
        public int Count(CategorySearchModel model)
        {
            int    result   = 0;
            string strQuery = "SELECT COUNT(cate.`id`)";

            strQuery += " FROM `product_category` cate LEFT JOIN (SELECT `id`, `name` FROM `product_category`) cate_parent";
            strQuery += " ON cate.`parent_id` = cate_parent.id WHERE 1";
            if (!string.IsNullOrEmpty(model.code) || !string.IsNullOrEmpty(model.name))
            {
                strQuery += (!string.IsNullOrEmpty(model.code)) ? " AND cate.`code` LIKE @code" : "";
                strQuery += (!string.IsNullOrEmpty(model.name)) ? " AND cate.`name` LIKE @name" : "";
                strQuery += " OR cate.`parent_id` IN (SELECT `id` FROM product_category WHERE 1";
                strQuery += (!string.IsNullOrEmpty(model.code)) ? " AND `code` LIKE @code" : "";
                strQuery += (!string.IsNullOrEmpty(model.name)) ? " AND `name` LIKE @name" : "";
                strQuery += ")";
            }
            result = (_db.ExecuteScalar <int>(strQuery, new { code = '%' + model.code + '%', name = '%' + model.name + '%' }));

            return(result);
        }
        private DataSet GetDataList(CategorySearchModel model)
        {
            try
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@companyId",   model.CompanyId),
                    new SqlParameter("@id",          model.Id),
                    new SqlParameter("@CurrentPage", model.page),
                    new SqlParameter("@PageSize",    model.pageSize),
                };

                var data = _spService.ExcuteSpAnonmious("prc_getCategorys", param, 2);;

                return(data);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #26
0
        public ActionResult Index(int?page, CategorySearchModel Model)
        {
            Model.searchResultModel = new List <CategoryViewModel>();
            Model.searchResultModel = _categoryBL.Search(Model);
            int Count = _categoryBL.Count(Model);

            TempData["SearchCount"] = Count + " row(s)";
            if (page.HasValue && Session[ScreenController] != null)
            {
                Model = (CategorySearchModel)Session[ScreenController];
            }
            else
            {
                Session[ScreenController] = Model;
            }
            var pageNumber = (page ?? 1);

            ViewBag.No = (pageNumber - 1) * 200;
            var list = Model.searchResultModel.ToPagedList(pageNumber, 200);

            return(PartialView("ListCategory", list));
        }
        private IQueryable <CategoryDto> GetDetail(CategorySearchModel searchModel)
        {
            IQueryable <CategoryDto> list = null;

            if (!searchModel.HasAnyValue())
            {
                list = _categoryService.GetAll();
            }
            else
            {
                var predicate = PredicateBuilder.True <CategoryDto>();

                if (!searchModel.CategoryName.IsNull())
                {
                    predicate = predicate.And(c => c.CategoryName.Contains(searchModel.CategoryName));
                }

                list = _categoryService.GetAll().AsExpandable().Where(predicate);
            }

            return(list);
        }
        public IActionResult CategoriesList(CategorySearchModel searchModel)
        {
            //retrieve categories
            var allCategories  = _categoryService.GetFullCategoryTree();
            var categoryModels = allCategories.Select(x =>
            {
                var model = _modelMapper.Map <CategoryModel>(x);
                model.FullCategoryPath =
                    _categoryAccountant.GetFullBreadcrumb(allCategories.First(y => y.Id == x.Id));
                return(model);
            })
                                 .Where(x => searchModel.SearchPhrase.IsNullEmptyOrWhiteSpace() || x.Name.StartsWith(searchModel.SearchPhrase, StringComparison.InvariantCultureIgnoreCase))
                                 .OrderBy(x => x.FullCategoryPath)
                                 .TakeFromPage(searchModel.Current, searchModel.RowCount)
                                 .ToList();

            return(R.Success
                   .With("total", allCategories.Count)
                   .With("current", searchModel.Current)
                   .With("rowCount", searchModel.RowCount)
                   .With("categories", categoryModels)
                   .Result);
        }
Exemple #29
0
        private void AddSearchModel(string urlTemplate, int pageSize, string manufacturer, string category = "35")
        {
            var ethicalNutrients = new CategorySearchModel
            {
                Name                  = "Chemist Warehouse",
                BaseUrl               = "http://www.chemistwarehouse.com.au",
                UrlTemplate           = urlTemplate,
                PageSize              = pageSize,
                ProductItemIdentifier = new Identifier
                {
                    Type  = IdentifierType.ElementContent,
                    Value = "//*[@class='product-container']"
                },
            };

            ethicalNutrients.AddIdentifier("Category", IdentifierType.Text, category);
            ethicalNutrients.AddIdentifier("Manufacturer", IdentifierType.Text, manufacturer);
            ethicalNutrients.AddIdentifier("ExternalStoreCode", IdentifierType.Text, "CW");
            ethicalNutrients.AddIdentifier("Name", IdentifierType.ElementContent, ".//*[@class='product-name']");
            ethicalNutrients.AddIdentifier("Url", IdentifierType.Attribute, "href");
            ethicalNutrients.AddIdentifier("ExternalId", IdentifierType.Attribute, "value", ".//input", true);
            ethicalNutrients.AddIdentifier("Price", IdentifierType.ElementContent, ".//*[@class='Price']", null, false, 1);
            SearchModels.Add(ethicalNutrients);
        }
Exemple #30
0
 public List <CategoryViewModel> Search(CategorySearchModel model)
 {
     return(_categoryDAO.Search(model));
 }