public async Task <IActionResult> OnGetAsync(int?id, string url) { if (id != null) { var blockThreeResult = await _repositoryWrapper.Article.ArticleGetByBlockId(id ?? 0); BlockThree = _maper.Map <List <ArticleGetByBlockIdDTO> >(blockThreeResult); } else { if (String.IsNullOrEmpty(url)) { return(NotFound()); } var articleCategory = await _repositoryWrapper.ArticleCategory.GetArticleCategoryByUrl(url.Trim()); if (articleCategory == null) { return(NotFound()); } var modelFilter = new ArticleSearchFilter(); modelFilter.ArticleCategoryId = articleCategory.Id; modelFilter.ExceptionArticleTop = true; modelFilter.Efficiency = true; modelFilter.CurrentPage = 1; modelFilter.PageSize = 8; modelFilter.FromDate = DateTime.Now.AddYears(-10); modelFilter.ToDate = DateTime.Now; var blockThreeResult = await _repositoryWrapper.Article.ArticleSearch(modelFilter); BlockThree = _maper.Map <List <ArticleGetByBlockIdDTO> >(blockThreeResult); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?ArticleCategoryId, string Keyword, int?p) { //Article = await ( from a in _context.Article orderby a.LastEditDate descending select a).ToListAsync(); var modelFilter = new ArticleSearchFilter(); modelFilter.Keyword = Keyword; modelFilter.ArticleCategoryId = ArticleCategoryId; modelFilter.CurrentPage = p ?? 1; modelFilter.PageSize = PageSize; modelFilter.FromDate = DateTime.Now.AddYears(-10); modelFilter.ToDate = DateTime.Now; if (!User.IsInRole("Quản trị hệ thống")) { modelFilter.CreateBy = _userManager.GetUserId(User); } var blockThreeResult = await _repositoryWrapper.Article.ArticleSearchWithPaging(modelFilter); Article = _maper.Map <List <Data.DataEntity.Article> >(blockThreeResult.Item1); this.ArticleCategoryId = ArticleCategoryId; this.Keyword = Keyword; Count = blockThreeResult.Item2; CurrentPage = p ?? 1; return(Page()); }
protected async Task InitData() { Logger.LogDebug("Init"); var modelFilter = new ArticleSearchFilter(); modelFilter.Keyword = keyword; modelFilter.ArticleCategoryId = articleCategorySelected; modelFilter.CurrentPage = p ?? 1; modelFilter.PageSize = 30; modelFilter.ArticleStatusId = articleStatusSelected; modelFilter.FromDate = DateTime.Now.AddYears(-10); modelFilter.ToDate = DateTime.Now; if (globalModel.user.IsInRole("Cộng tác viên")) { modelFilter.CreateBy = globalModel.userId; } if (globalModel.user.IsInRole("Phụ trách chuyên mục")) { modelFilter.AssignBy = globalModel.userId; } var result = await Repository.Article.ArticleSearchWithPaging(modelFilter); lstArticle = result.Items; totalCount = result.TotalSize; //Init Selected listArticleSelected.Clear(); StateHasChanged(); }
static void Main(string[] args) { var log = LogManager.GetLogger(typeof(Program)); const int pageSize = 5; const int pageNumber = 1; var kernel = new StandardKernel(); var config = new MapperConfiguration(cfg => cfg.AddProfile <MappingProfile>()); kernel.Bind <IMapper>().ToConstant(config.CreateMapper()); kernel.Bind <IEIndexContext>().To <IEIndexContext>().InTransientScope(); var mapper = kernel.Get <IMapper>(); var context1 = kernel.Get <IEIndexContext>(); //context1.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); using (var uow = new UnitOfWork <IEIndexContext>(context1)) { var articleService = new ArticleService(uow, mapper, log); var filter = new ArticleSearchFilter { Issue = "fall" }; //var filter = new ArticleSearchFilter (); var articles = articleService.GetEntities(filter.Filter(), pageSize: pageSize, pageNumber: pageNumber) .ToList(); //var articles = articleService.GetEntities(pageSize: pageSize, pageNumber: pageNumber) // .ToList(); var articlesWithChildren = articleService.GetFullEntities(filter.Filter(), pageSize: pageSize, pageNumber: pageNumber) .ToList(); } var context2 = kernel.Get <IEIndexContext>(); //context2.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); using (var uow = new UnitOfWork <IEIndexContext>(context2)) { var authorService = new AuthorService(uow, mapper, log); var authors = authorService.GetEntities(pageSize: pageSize, pageNumber: pageNumber) .ToList(); var authorsWithChildren = authorService.GetFullEntities(pageSize: pageSize, pageNumber: pageNumber) .ToList(); } var context3 = kernel.Get <IEIndexContext>(); //context3.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); using (var uow = new UnitOfWork <IEIndexContext>(context3)) { var subjectService = new SubjectService(uow, mapper, log); var subjects = subjectService.GetEntities(pageSize: pageSize, pageNumber: pageNumber) .ToList(); var subjectsWithChildren = subjectService.GetFullEntities(pageSize: pageSize, pageNumber: pageNumber) .ToList(); } }
public async Task <List <ArticleSearch_Result> > ArticleSearch(ArticleSearchFilter model) { var output = new List <ArticleSearch_Result>(); //Parameter var pKeyword = new SqlParameter("@Keyword", model.Keyword ?? (object)DBNull.Value); var pTags = new SqlParameter("@Tags", model.Tags ?? (object)DBNull.Value); var pArticleCategoryId = new SqlParameter("@ArticleCategoryId", model.ArticleCategoryId ?? (object)DBNull.Value); var pProductBrandId = new SqlParameter("@ProductBrandId", model.ProductBrandId ?? (object)DBNull.Value); var pArticleTypeId = new SqlParameter("@ArticleTypeId", model.ArticleTypeId ?? (object)DBNull.Value); var pExceptionId = new SqlParameter("@ExceptionId", model.ExceptionId ?? (object)DBNull.Value); var pExceptionArticleTop = new SqlParameter("@ExceptionArticleTop", model.ExceptionArticleTop ?? (object)DBNull.Value); var pFromDate = new SqlParameter("@FromDate", model.FromDate); var pToDate = new SqlParameter("@ToDate", model.ToDate); var pEfficiency = new SqlParameter("@Efficiency", model.Efficiency ?? (object)DBNull.Value); var pActive = new SqlParameter("@Active", model.Active ?? (object)DBNull.Value); var pCreateBy = new SqlParameter("@CreateBy", model.CreateBy ?? (object)DBNull.Value); var pPageSize = new SqlParameter("@PageSize", model.PageSize ?? 10); var pCurrentPage = new SqlParameter("@CurrentPage", model.CurrentPage ?? 1); var pItemCount = new SqlParameter("@ItemCount", SqlDbType.Int) { Direction = ParameterDirection.Output }; try { output = await CmsContext.Set <ArticleSearch_Result>() .FromSqlRaw($"EXECUTE dbo.ArticleSearch " + $"@Keyword = @Keyword, " + $"@Tags = @Tags, " + $"@ArticleCategoryId = @ArticleCategoryId, " + $"@ProductBrandId = @ProductBrandId, " + $"@ArticleTypeId = @ArticleTypeId, " + $"@ExceptionId = @ExceptionId, " + $"@ExceptionArticleTop = @ExceptionArticleTop, " + $"@FromDate = @FromDate, " + $"@ToDate = @ToDate, " + $"@Efficiency = @Efficiency, " + $"@Active = @Active, " + $"@CreateBy = @CreateBy, " + $"@PageSize = @PageSize, " + $"@CurrentPage = @CurrentPage, " + $"@ItemCount = @ItemCount out" , pKeyword, pTags, pArticleCategoryId, pProductBrandId, pArticleTypeId, pExceptionId, pExceptionArticleTop, pFromDate, pToDate, pEfficiency, pActive, pCreateBy, pPageSize, pCurrentPage, pItemCount ) .AsTracking() .ToListAsync(); } catch { } return(output); }
/// <summary> /// 記事一覧を取得 /// </summary> /// <param name="page">表示ページ</param> /// <returns></returns> public ActionResult List(string id, int page = 0) { if (page < 0) { page = 0; } var filter = ArticleSearchFilter.CreateForManage(id); filter.PageNum = page; var list = _service.RetrieveArticleList(filter); return(View(list)); }
public async Task <IActionResult> OnGetAsync(string keyword) { var modelFilter = new ArticleSearchFilter(); modelFilter.Keyword = keyword; modelFilter.CurrentPage = 1; modelFilter.PageSize = 10; modelFilter.FromDate = DateTime.Now.AddYears(-10); modelFilter.ToDate = DateTime.Now; var results = await _repositoryWrapper.Article.ArticleSearch(modelFilter); ListArticle = _maper.Map <List <ArticleDTO> >(results); ViewData["keyword"] = keyword; return(Page()); }
/// <summary> /// カテゴリに関連する記事の一覧を表示する /// カテゴリが未指定の場合は、最新記事を取得する /// </summary> /// <param name="id">カテゴリの名前かID</param> /// <returns></returns> public ActionResult Archives(string id, int page = 0) { // チェック if (page < 0) { page = 0; } var filter = ArticleSearchFilter.CreateForPublic(id, Request.IsAuthenticated); filter.PageNum = page; var model = _service.RetrieveArticleList(filter); return(View(model)); }
public async Task <IActionResult> OnGetAsync(int id) { var articleTopBlockOne = new ArticleGetTopByCategoryId_Result(); //Nếu muốn thêm category thì add thêm tuple vào block one var cateBlockOne = new List <Tuple <ArticleGetTopByCategoryIdDTO, List <ArticleSearchDTO>, ArticleCategoryDTO> >(); //GetCategory var articleCate = await _repositoryWrapper.ArticleCategory.FirstOrDefaultAsync(p => p.Id == id); //Get Category block One var articleTop = await _repositoryWrapper.Article.ArticleGetTopByCategoryId(id); if (articleTop.Count > 0) { articleTopBlockOne = articleTop.Take(1).OrderBy(p => p.LastEditDate).FirstOrDefault(); } //ArticleSearch var modelFilter = new ArticleSearchFilter(); modelFilter.ArticleCategoryId = id; modelFilter.ExceptionArticleTop = true; modelFilter.Efficiency = true; modelFilter.CurrentPage = 1; modelFilter.PageSize = 2; modelFilter.FromDate = DateTime.Now.AddYears(-10); modelFilter.ToDate = DateTime.Now; var lstArticle = await _repositoryWrapper.Article.ArticleSearch(modelFilter); var item1 = Tuple.Create(_maper.Map <ArticleGetTopByCategoryIdDTO>(articleTopBlockOne), _maper.Map <List <ArticleSearchDTO> >(lstArticle), _maper.Map <ArticleCategoryDTO>(articleCate)); cateBlockOne.Add(item1); //Set value CategoryBlockOne = cateBlockOne; return(Page()); }
protected async Task InitData() { var modelFilter = new ArticleSearchFilter(); modelFilter.Keyword = keyword; modelFilter.ArticleCategoryId = articleCategorySelected; modelFilter.CurrentPage = p ?? 1; modelFilter.PageSize = 30; modelFilter.ArticleStatusId = articleStatusSelected; modelFilter.FromDate = DateTime.Now.AddYears(-10); modelFilter.ToDate = DateTime.Now; if (!user.IsInRole("Quản trị hệ thống")) { modelFilter.CreateBy = Guid.Parse(UserManager.GetUserId(user)); } var result = await Repository.Article.ArticleSearchWithPaging(modelFilter); lstArticle = result.Items; totalCount = result.TotalSize; //Init Selected listArticleSelected.Clear(); StateHasChanged(); }
public async Task <VirtualizeResponse <SpArticleSearchResult> > ArticleSearchWithPaging(ArticleSearchFilter model) { var output = new VirtualizeResponse <SpArticleSearchResult>(); var itemCounts = new OutputParameter <int?>(); var returnValues = new OutputParameter <int>(); var result = await CmsContext.GetProcedures().SpArticleSearchAsync( model.Keyword, model.ArticleCategoryId, model.ArticleStatusId, model.ProductBrandId, model.ArticleTypeId, model.ExceptionId, model.ExceptionArticleTop, model.FromDate, model.ToDate, model.Efficiency, model.Active, model.AssignBy, model.CreateBy, model.PageSize, model.CurrentPage, itemCounts, returnValues ); output.Items = result.ToList(); output.TotalSize = (int)itemCounts.Value; return(output); }