public IActionResult AddNote() { AddNoteVM vm = new AddNoteVM(); vm.Categories = Mapper.Map <IEnumerable <Category>, List <SelectListItem> >(_categoryService.GetAll()); vm.Projects = Mapper.Map <IEnumerable <Project>, List <SelectListItem> >(_projectService.GetAll()); vm.Tags = Mapper.Map <IEnumerable <Tag>, List <SelectListItem> >(_tagService.GetAll()); return(View(vm)); }
private void Button_Add_Click(object sender, RoutedEventArgs e) { try { AddNoteVM addVM = new AddNoteVM(this.connector); AddNoteVC addNote = new AddNoteVC(addVM); ContentWindow window = new ContentWindow("Add Note", addNote); window.SetIcon("addIcon"); window.SetSize(500, 500); window.ShowDialog(); this.mainVM.RefreshNotes(); } catch (Exception ex) { MainVC.logFile.Error(ex); MessageBox.Show(ex.Message); } }
public RedirectToActionResult InsertNote(AddNoteVM note) { if (ModelState.IsValid) { try { Note newNote = Mapper.Map <AddNoteVM, Note>(note); newNote.CreateBy = GetProfile(this.User).Id; newNote.CreationDate = DateTime.Now; _noteService.Add(newNote); } catch (Exception e) { Console.WriteLine(e); throw; } } return(RedirectToAction("Note")); }
public AddNoteVC(AddNoteVM viewModel) { InitializeComponent(); this.viewModel = viewModel; this.DataContext = this.viewModel; }