public IActionResult Category(string slug) { if (string.IsNullOrWhiteSpace(slug)) { return(NotFound()); } var category = _categoryService.GetCategoryBySlug(slug); if (category == null) { return(NotFound()); } if (!category.IsVisible) { if (!HttpContext.User.IsInRole(Administrator)) { return(NotFound()); } } if (HttpContext.User.IsInRole(Administrator)) { PagedDtoList <NoteDto> notes = _noteService.GetNotesByCategorySlug(Visibility.All, slug, CurrentPage, PageSize); ViewBag.CategoryTitle = category.Title; return(View(notes)); } else { PagedDtoList <NoteDto> notes = _noteService.GetNotesByCategorySlug(Visibility.Visible, slug, CurrentPage, PageSize); ViewBag.CategoryTitle = category.Title; return(View(notes)); } }
public IActionResult Index(string slug) { if (string.IsNullOrWhiteSpace(slug)) { return(BadRequest()); } var tagDto = _tagService.GetBySlug(slug); if (tagDto == null) { return(NotFound()); } if (tagDto.IsHidden) { if (!HttpContext.User.IsInRole(Administrator)) { return(NotFound()); } } if (HttpContext.User.IsInRole(Administrator)) { PagedDtoList <NoteDto> notes = _noteService.FindNotesByTagSlug(Visibility.All, slug, CurrentPage, PageSize); ViewBag.SelectedTag = tagDto.Title; return(View(notes)); } else { PagedDtoList <NoteDto> notes = _noteService.FindNotesByTagSlug(Visibility.Visible, slug, CurrentPage, PageSize); ViewBag.SelectedTag = tagDto.Title; return(View(notes)); } }
public IActionResult Archive(int year, int month) { ViewBag.SelectedYear = year; ViewBag.SelectedMonth = month; PagedDtoList <NoteDto> notes = _noteService.GetNotes(year, month, CurrentPage, PageSize); return(View(notes)); }
public ActionResult Notes_Read([DataSourceRequest] DataSourceRequest request, string searchTerm, int[] selectedCategories, int[] selectedTags) { if (searchTerm == null) { searchTerm = string.Empty; } PagedDtoList <NoteDto> filteredNotes = _noteService.FindNotes(searchTerm, selectedCategories, selectedTags, request.Page, request.PageSize); return(Json(new CustomDataSourceResult { Data = filteredNotes, Total = filteredNotes.TotalItemCount })); }