public IActionResult Create(int?selectedNotebookId) { if (selectedNotebookId == null) { TempData[nameof(ErrorMessageKey)] = "Notebook not selected. If not exist, please create new and select"; return(RedirectToAction(nameof(Index))); } var allNotebooks = notebookRepository.List().ToList(); var selectedNotebook = allNotebooks.SingleOrDefault(b => b.Id == selectedNotebookId); var allNotesForSelectedNotebook = noteRepository.List() .Where(n => n.Notebook.Id == selectedNotebookId) .Include(n => n.Tags) .AsEnumerable() .Select(n => new NoteViewModel() { Id = n.Id, Title = n.Title, Content = n.Content, NotebookId = n.NotebookId, Tags = string.Join(", ", n.Tags.Select(t => t.Name)), }) .ToList(); var model = new NoteIndexViewModel() { AllNotebooks = allNotebooks, SelectedNotebook = selectedNotebook, AllNotesForSelectedNotebook = allNotesForSelectedNotebook, }; return(View(nameof(Index), model)); }
public ActionResult ByCategory(int id) { NoteIndexViewModel model; CategoryDTO category = _bl.Categories.GetItemById(id); if (category == null) { model = new NoteIndexViewModel() { Title = $"Заметки", Categories = _bl.Categories.GetList(), Notes = _bl.Notes.GetList() }; } else { model = new NoteIndexViewModel() { Title = $"Заметки по категории {category.Name}", Categories = _bl.Categories.GetList(), Notes = _bl.Notes.GetNotesByCategoryId(id) }; } return(View("Index", model)); }
public IActionResult Index(int?selectedNotebookId, int?selectedNoteId) { var allNotebooks = this.notebookRepository.List().ToList(); var selectedNotebook = allNotebooks.SingleOrDefault(b => b.Id == selectedNotebookId); var allNotesForSelectedNotebook = noteRepository.List() .Where(n => n.Notebook.Id == selectedNotebookId) .Include(n => n.Tags) .AsEnumerable() .Select(n => new NoteViewModel() { Id = n.Id, Title = n.Title, Content = n.Content, NotebookId = n.NotebookId, Tags = string.Join(", ", n.Tags.Select(t => t.Name)), }) .ToList(); var selectedNote = allNotesForSelectedNotebook.SingleOrDefault(n => n.Id == selectedNoteId); var model = new NoteIndexViewModel() { AllNotebooks = allNotebooks, SelectedNotebook = selectedNotebook, AllNotesForSelectedNotebook = allNotesForSelectedNotebook, SelectedNote = selectedNote }; return(View(model)); }
public IActionResult Index(int gameID) { var model = new NoteIndexViewModel(); model.GameID = gameID; model.Notes = work.NoteRepository.GetAllForGame(gameID).Select(e => NoteModel.GenerateNoteModelFromDTO(e)); return(View(model)); }
// GET: Note public ActionResult Index() { NoteIndexViewModel model = new NoteIndexViewModel() { Notes = _bl.Notes.GetList(1, 10), Categories = _bl.Categories.GetList() }; return(View(model)); }
public IActionResult Filter(NoteIndexViewModel model) { foreach (var n in Notes) { if (n.Date >= model.DateFrom && n.Date <= model.DateTo && n.Categories.Contains(model.Category)) { model.Notes.Add(n); } } return(View("Index", model)); }
public async Task <IActionResult> IndexAsync() { var noteResult = await webApiService.GetNoteDtosAsync(); var viewModel = new NoteIndexViewModel() { NoteDtos = noteResult.Data }; ViewData["Notes"] = JsonConvert.SerializeObject(viewModel.NoteDtos); return(View(viewModel)); }