Example #1
0
 public NotesListPage()
 {
     InitializeComponent();
     BindingContext = new NotesListViewModel {
         Navigation = this.Navigation
     };
 }
        //public IActionResult Create()
        //{
        //    return View();
        //}

        //[HttpPost]
        //public async Task<IActionResult> Create(Note note)
        //{
        //    db.Notes.Add(note);
        //    await db.SaveChangesAsync();
        //    return RedirectToAction("Index");
        //}

        //public async Task<IActionResult> Edit(int? id)
        //{
        //    if (id != null)
        //    {
        //        Note note = await db.Notes.FirstOrDefaultAsync(p => p.Id == id);
        //        if (note != null)
        //            return View(note);
        //    }
        //    return NotFound();
        //}
        //[HttpPost]
        //public async Task<IActionResult> Edit(Note phone)
        //{
        //    db.Notes.Update(phone);
        //    await db.SaveChangesAsync();
        //    return RedirectToAction("Index");
        //}

        //[HttpGet]
        //[ActionName("Delete")]
        //public async Task<IActionResult> ConfirmDelete(int? id)
        //{
        //    if (id != null)
        //    {
        //        Note note = await db.Notes.FirstOrDefaultAsync(p => p.Id == id);
        //        if (note != null)
        //            return View(note);
        //    }
        //    return NotFound();
        //}

        //[HttpPost]
        //public async Task<IActionResult> Delete(int? id)
        //{
        //    if (id != null)
        //    {
        //        Note note = await db.Notes.FirstOrDefaultAsync(p => p.Id == id);
        //        if (note != null)
        //        {
        //            db.Notes.Remove(note);
        //            await db.SaveChangesAsync();
        //            return RedirectToAction("Index");
        //        }
        //    }
        //    return NotFound();
        //}


        public ActionResult Index(int?typenote, string name)
        {
            IQueryable <Note> notes = db.Notes.Include(p => p.TypeNote);

            if (typenote != null && typenote != 0)
            {
                notes = notes.Where(p => p.TypeNoteId == typenote);
            }
            if (!String.IsNullOrEmpty(name))
            {
                notes = notes.Where(p => p.ThisNote.Contains(name));
            }

            List <TypeNote> typenotes = db.TypeNotes.ToList();

            typenotes.Insert(0, new TypeNote {
                NameType = "Все", Id = 0
            });

            NotesListViewModel viewModel = new NotesListViewModel
            {
                Notes     = notes.ToList(),
                TypeNotes = new SelectList(typenotes, "Id", "NameType"),
                Name      = name
            };

            return(View(viewModel));
        }
Example #3
0
        public MainPage()
        {
            _vm            = new NotesListViewModel();
            BindingContext = _vm;

            InitializeComponent();
        }
Example #4
0
        public IActionResult List()
        {
            ViewBag.Title = "Welcome to the Goal App";
            NotesListViewModel notesListViewModel = new NotesListViewModel();

            notesListViewModel.Notes = _noteRepository.AllNotes();
            return(View(notesListViewModel));
        }
Example #5
0
        public MainPage()
        {
            var locator = (ViewModelLocator)Application.Current.Resources["Locator"];

            ViewModel = locator.NotesListVm;

            this.InitializeComponent();
        }
Example #6
0
        public IActionResult Edit(int id)
        {
            NotesListViewModel notesListViewModel = new NotesListViewModel();
            var currentNote = _noteRepository.GetNoteById(id);

            notesListViewModel.Note = currentNote;

            return(View(notesListViewModel));
        }
Example #7
0
        // GET: Notes
        public ActionResult ShowNotes(NotesFilter filter, FetchOptions options)
        {
            var model = new NotesListViewModel
            {
                Notes = notesMethods.GetUsersNotes(CurrentUser, filter, options)
            };

            return(View(model));
        }
        public ActionResult ShowNotes(User user, NoteFilter filter, FetchOptions options)
        {
            var model = new NotesListViewModel
            {
                Notes = noteRepository.GetUsersNotes(CurrentUser, filter, options)
            };

            return(View(model));
        }
Example #9
0
        async void OnDelete(object sender, EventArgs e)
        {
            Notes_database = MtSql.Current.GetConnectionAsync("notesDb");

            var        mi           = ((MenuItem)sender);
            NotesModel noteToDelete = (CalendarApp.Model.NotesModel)mi.CommandParameter;
            await Notes_database.DeleteAsync(noteToDelete);

            BindingContext = new NotesListViewModel(Navigation);
        }
Example #10
0
        public async Task <IActionResult> AllAsync()
        {
            var user = await this.userManager.GetUserAsync(this.User);

            var viewModel = new NotesListViewModel
            {
                Notes = this.notesService.GetAll(user),
            };

            return(this.View(viewModel));
        }
Example #11
0
        public NotesListPage1()
        {
            notesListViewModel = new NotesListViewModel(Store.Notes)
            {
                Navigation = this.Navigation
            };

            var stackLayout = new StackLayout {
                Margin = new Thickness(20, 0, 20, 0)
            };
            var createButton = new Button {
                Text = "Добавить", Command = notesListViewModel.CreateNoteCommand
            };

            var listView = new ListView()
            {
                ItemsSource = notesListViewModel.Notes, HasUnevenRows = true
            };

            //var binding = new Binding { Source = notesListViewModel.SelectedNote, Mode = BindingMode.TwoWay };

            //listView.SelectedItem = binding;
            listView.ItemTapped  += (s, e) => notesListViewModel.SelectedNote = (NoteViewModel)((ListView)s).SelectedItem;
            listView.ItemTemplate = new DataTemplate(() =>
            {
                Label nameLabel = new Label();
                nameLabel.SetBinding(Label.TextProperty, "Name");

                Label descriptionLabel = new Label();
                descriptionLabel.SetBinding(Label.TextProperty, "Description");

                return(new ViewCell
                {
                    View = new StackLayout
                    {
                        Padding = new Thickness(0, 5),
                        Orientation = StackOrientation.Vertical,
                        Children = { nameLabel, descriptionLabel }
                    }
                });
            });
            stackLayout.Children.Add(createButton);
            stackLayout.Children.Add(listView);

            Content = stackLayout;
        }
Example #12
0
        public ViewResult List(string category, int page = 1)
        {
            NotesListViewModel model = new NotesListViewModel
            {
                Notes = repository.notes
                        .Where(p => category == null || p.Category == category)
                        .OrderBy(p => p.NoteId)
                        .Skip((page - 1) * PageSize)
                        .Take(PageSize),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageSize,
                    TotalItems   = category == null?
                                   repository.notes.Count() :
                                       repository.notes.Where(p => p.Category == category).Count()
                },
                CurrentCategory = category
            };

            return(View(model));
        }
Example #13
0
        public NotesListViewModel GetNotesViewModel(string orderBy, bool hideFinished)
        {
            var notesQuery = _db.Notes.AsQueryable();

            if (hideFinished)
            {
                notesQuery = notesQuery.Where(n => !n.FinishedAt.HasValue);
            }

            if (orderBy == "createdAt")
            {
                notesQuery = notesQuery.OrderByDescending(n => n.CreatedAt);
            }
            else if (orderBy == "finishedAt")
            {
                notesQuery = notesQuery.OrderByDescending(n => n.FinishedAt);
            }
            else if (orderBy == "importance")
            {
                notesQuery = notesQuery.OrderByDescending(n => n.Importance);
            }

            var notes = notesQuery.ToList().Select(MapToViewModel).ToList();
            var availableSortOrders = _userSettingsService.GetAvailableSortOrderLabelByKeys();
            var currentSortOrder    = _userSettingsService.GetCurrentSortOrderKey();

            var viewModel = new NotesListViewModel
            {
                CurrentSortOrder    = currentSortOrder,
                AvailableSortOrders = availableSortOrders,
                HideFinished        = hideFinished,
                Notes = notes
            };

            return(viewModel);
        }
Example #14
0
        public IActionResult Create()
        {
            NotesListViewModel notesListViewModel = new NotesListViewModel();

            return(View(notesListViewModel));
        }
Example #15
0
 protected override void OnAppearing()
 {
     NoteslistView.SelectedItem = null;
     BindingContext             = new NotesListViewModel(Navigation);
 }
Example #16
0
 public Notes()
 {
     InitializeComponent();
     BindingContext = new NotesListViewModel(Navigation);
 }