private void DoShowNext()
        {
            var studentVote = StudentVotes.FirstOrDefault(c => c.Position.Id == CurrentPosition.Id);

            if (studentVote != null)
            {
                studentVote.VotedStudent = SelectedCouncilMember?.Student;
                StudentVotes.Remove(studentVote);
                AddVote();
                StudentVotes = StudentVotes.OrderBy(c => c.Position.Id).ToObservableCollection();
            }
            else
            {
                AddVote();
            }



            if (CouncilPositions.IndexOf(CurrentPosition) == CouncilPositions?.IndexOf(CouncilPositions.Last()))
            {
                DialogHost.CloseDialogCommand.Execute("Finish", null);

                RaisePropertyChanged(() => VoteCommand);
            }
            else
            {
                NextPosition();
            }
            RaisePropertyChanged(() => NextOrFinish);
        }
 private void DoVote()
 {
     //await DialogHost.Show(new ElectionVoteView() {DataContext = this}, "RootDialog",
     //    delegate(object sender, DialogOpenedEventArgs args)
     //    {
     //        CurrentPosition = CouncilPositions.FirstOrDefault();
     //        CouncilMembersList = _context.CouncilMembers.AsNoTracking().Where(c => c.CouncilPosition.Id == CurrentPosition.Id)
     //            .ToList();
     //    },
     //    delegate(object sender, DialogClosingEventArgs args)
     //    {
     //        if (Equals(args.Parameter, false))
     //        {
     //            StudentVotes?.Clear();
     //            return;
     //        }
     //        if (Equals(args.Parameter, "Finish"))
     //        {
     //            args.Cancel();
     //            args.Session.UpdateContent(new OkMessageDialog(){DataContext = "OK FINISH"});
     //        }
     //    });
     CurrentPosition    = CouncilPositions.FirstOrDefault();
     CouncilMembersList = _context.CouncilMembers.AsNoTracking().Where(c => c.CouncilPosition.Id == CurrentPosition.Id)
                          .ToList();
     Messenger.Default.Send(new SetNavigation {
         Content = new ElectionVoteView {
             DataContext = new ElectionVoteViewModel(_context, CurrentStudent)
         }
     });
 }
 private void DoChangeVote()
 {
     IsNotFinish     = true;
     _isVoteChange   = true;
     _oldPosition    = CurrentPosition;
     CurrentPosition = CouncilPositions.FirstOrDefault(c => c.Id == SelectedVote.Position.Id);
 }
 public ElectionVoteViewModel(MorenoContext context, Student student)
 {
     _context         = context;
     CurrentStudent   = student;
     CouncilPositions = _context.CouncilPositions.ToList();
     CurrentPosition  = CouncilPositions.FirstOrDefault();
     StudentVotes     = new ObservableCollection <StudentVote>();
     IsNotFinish      = true;
 }
        private void DoShowNext()
        {
            if (StudentVotes != null)
            {
                var studentVote = StudentVotes.FirstOrDefault(c => c.Position.Id == CurrentPosition.Id);
                if (studentVote != null)
                {
                    studentVote.VotedStudent = SelectedCouncilMember?.Student;
                    StudentVotes.Remove(studentVote);
                    AddVote();
                    StudentVotes = StudentVotes.OrderBy(c => c.Position.Id).ToObservableCollection();
                }
                else
                {
                    AddVote();
                }
            }
            else
            {
                AddVote();
            }

            if (_changeOnly)
            {
                IsNotFinish = false;
            }

            if (_isVoteChange)
            {
                _isVoteChange   = false;
                CurrentPosition = _oldPosition;
                RaisePropertyChanged(() => NextOrFinish);
                return;
            }

            if (CouncilPositions.IndexOf(CurrentPosition) == CouncilPositions?.IndexOf(CouncilPositions.Last()))
            {
                IsNotFinish = false;
                _changeOnly = true;
            }
            else
            {
                NextPosition();
            }
            RaisePropertyChanged(() => NextOrFinish);
        }
 private void PreviousPosition()
 {
     CurrentPosition    = CouncilPositions.PreviousOf(CurrentPosition);
     CouncilMembersList = _context.CouncilMembers.AsNoTracking().Where(c => c.CouncilPosition.Id == CurrentPosition.Id)
                          .ToList();
 }
 private void NextPosition()
 {
     CurrentPosition = CouncilPositions?.NextOf(CurrentPosition);
     //CouncilMembersList = _context.CouncilMembers.AsNoTracking().Where(c => c.CouncilPosition.Id == CurrentPosition.Id)
     //    .ToList();
 }