public ActionResult EntryList(EntryGetPageDTO dto) { EntryListViewModel model = new EntryListViewModel(); dto.CurrentIndex = (dto.PageIndex - 1) * dto.PageSize; EntrySearchResult result = entryService.GetPageByTrainId(dto); model.TrainId = dto.Id; //model.Cities = idNameService.GetAll("市级"); model.Entries = result.Entries; //分页 Pagination pager = new Pagination(); pager.PageIndex = dto.PageIndex; pager.PageSize = 20; pager.TotalCount = result.TotalCount; if (result.TotalCount <= 20) { model.Page = ""; } else { model.Page = pager.GetPagerHtml(); } return(Json(new AjaxResult { Status = "1", Data = model })); }
public IActionResult SortByMonth(int _year, int _month) { List <Entry> entries = new List <Entry>(); List <DateTime> dates = new List <DateTime>(); List <Entry> allEntries = _context.Entries.ToList(); foreach (Entry entry in allEntries) { dates.Add(entry.DateOfCreation); } entries = _context.Entries.Where(e => e.DateOfCreation.Year == _year && e.DateOfCreation.Month == _month).ToList(); foreach (Entry entry in entries) { entry.NumberOfComments = _context.Comments.Where(e => e.EntryId == entry.EntryId).Count(); entry.CategoryName = _context.Categories.FirstOrDefault(category => category.CategoryId == entry.CategoryId).CategoryName; } List <Category> categories = _context.Categories.OrderBy(c => c.CategoryName).ToList(); EntryListViewModel model = new EntryListViewModel(); model.Entries = entries; model.Categories = categories; model.Dates = dates; return(View("EntryList", model)); }
public ActionResult EntryList(long id = 0, int pageIndex = 1) { EntryListViewModel model = new EntryListViewModel(); EntryGetPageDTO dto = new EntryGetPageDTO(); dto.Id = id; EntrySearchResult result = entryService.GetPageByTrainId(dto); model.TrainId = id; model.Cities = idNameService.GetAll("市级"); model.Entries = result.Entries; //分页 Pagination pager = new Pagination(); pager.PageIndex = pageIndex; pager.PageSize = 20; pager.TotalCount = result.TotalCount; if (result.TotalCount <= 20) { model.Page = ""; } else { model.Page = pager.GetPagerHtml(); } return(View(model)); }
public IActionResult All() { var vm = new EntryListViewModel() { ShowEdit = true, Entries = _repo.GetAllEntries().OrderBy(e => e.NameLowerCase).ToList() }; return(View(vm)); }
public ActionResult Index(int page = 1) { if (page < 1) { return(HttpNotFound()); } EntryListViewModel model = new EntryListViewModel(); var PostPerPage = Convert.ToInt32(ViewData["EntryPerPage"]); var entries = from Entries in db.Entries where Entries.Type == EntryType.Post where Entries.Status == StatusType.Published where Entries.CreatedAt < DateTime.Now join Author in db.Authors on Entries.AuthorID equals Author.ID select Entries; model.CurrentPage = page; var EntryCount = entries.Count(); var TotalPage = (double)EntryCount / PostPerPage; model.PageCount = (int)Math.Ceiling(TotalPage); var skip = (page - 1) * PostPerPage; model.Entries = (from e in entries select new EntryViewModel { ID = e.ID, Title = e.Title, Author = new LinkViewModel { Title = e.Author.FirstName, Slug = e.Author.ID.ToString() }, Content = e.Content, Slug = e.Slug, DateTime = e.UpdatedAt, Categories = (from Categories in e.Categories select new LinkViewModel { Title = Categories.Name, Slug = Categories.Slug }) .ToList() }) .OrderByDescending(p => p.ID) .Skip(skip) .Take(PostPerPage) .ToList(); return(View(model)); }
public IActionResult Search(string _headline, int _categoryId) { List <Entry> entries = new List <Entry>(); List <DateTime> dates = new List <DateTime>(); List <Entry> allEntries = _context.Entries.ToList(); foreach (Entry entry in allEntries) { dates.Add(entry.DateOfCreation); } if (_categoryId == 0 && _headline == null) { return(RedirectToAction("EntryList")); } else if (_categoryId == 0) { entries = _context.Entries.Where(entry => entry.Headline.Contains(_headline)).ToList(); } else if (_headline == null) { entries = _context.Entries.Where(entry => entry.CategoryId == _categoryId).ToList(); } else { entries = _context.Entries.Where(entry => entry.Headline.Contains(_headline) && entry.CategoryId == _categoryId).ToList(); } List <Category> categories = _context.Categories.OrderBy(c => c.CategoryName).ToList(); foreach (Entry entry in entries) { entry.NumberOfComments = _context.Comments.Where(e => e.EntryId == entry.EntryId).Count(); entry.CategoryName = _context.Categories.FirstOrDefault(category => category.CategoryId == entry.CategoryId).CategoryName; } EntryListViewModel model = new EntryListViewModel(); model.Entries = entries; model.Categories = categories; model.Dates = dates; return(View("EntryList", model)); }
public IActionResult EntryList() { List <Entry> entries = _context.Entries.OrderByDescending(e => e.DateOfCreation).ToList(); List <Category> categories = _context.Categories.OrderBy(c => c.CategoryName).ToList(); List <DateTime> dates = new List <DateTime>(); foreach (Entry entry in entries) { entry.NumberOfComments = _context.Comments.Where(e => e.EntryId == entry.EntryId).Count(); entry.CategoryName = _context.Categories.FirstOrDefault(category => category.CategoryId == entry.CategoryId).CategoryName; dates.Add(entry.DateOfCreation); } EntryListViewModel model = new EntryListViewModel(); model.Entries = entries; model.Categories = categories; model.Dates = dates; return(View(model)); }
private GeneralDisplayViewModel CreateGeneralDisplayViewModel(StandardFilter standardFilter) { // load the data IEnumerable <IEntry> entries = EntryContext.LoadEntries(standardFilter); // register parsers EntryParsing.Register(GraphProcessor); EntryParsing.Register(StatisticsProcessor); // parse data EntryParsing.Parse(entries); // create EntryListViewModel EntryListViewModel entryListViewModel = new EntryListViewModel(entries); // create EntriesGraphViewModel EntriesGraphViewModel entriesGraphViewModel = new EntriesGraphViewModel(GraphProcessor.Result); // create EntriesStatisticsViewModel EntriesStatisticsViewModel entriesStatisticsViewModel = new EntriesStatisticsViewModel(StatisticsProcessor.Result); //TODO: move filter to another action and create sepparate call for it or something // get filter data IFilterData filterData = EntryContext.GetFilterData(); // create FilterViewModel FilterViewModel filterViewModel = new FilterViewModel(filterData); // create generalDisplayViewModel GeneralDisplayViewModel generalDisplayViewModel = new GeneralDisplayViewModel(entryListViewModel, entriesGraphViewModel, entriesStatisticsViewModel, filterViewModel); // return ... return(generalDisplayViewModel); }
protected override void OnDisappearing() { base.OnDisappearing(); viewModel = null; BindingContext = null; }
protected override void OnAppearing() { base.OnAppearing(); viewModel = new EntryListViewModel(new SendService(), this.Navigation); BindingContext = viewModel; }