Example #1
0
        public ChangeBeltForPromotion(ref PromotedPerson person, ref ObservableCollection <PromotedPerson> PromotedPersonsList)
        {
            _promotedPerson = person;
            _connection     = DependencyService.Get <ISQLiteDb>().GetConnection();
            _newBelt        = new Belt();
            _list           = PromotedPersonsList;

            InitializeComponent();
        }
        private async void ReceiveMultiselectedPersons(MultiselectPersonsPage sender, ObservableCollection <Person> args)
        {
            foreach (var Person in args)
            {
                Belt NewBelt = await GlobalMethods.DbHelper.GetChosenBelt(_connection, Person.BeltId);

                PromotedPerson PersonToBePromoted = new PromotedPerson(Person, NewBelt);
                PersonToBePromoted.IsPromotionOK = false;
                Participants.Add(PersonToBePromoted);
            }
            NoOfParticipants.Text = Participants.Count.ToString();
        }
        private void ParticipantsList_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem == null)
            {
                return;
            }
            ParticipantsList.SelectedItem = null;

            PromotedPerson toSend = e.SelectedItem as PromotedPerson;

            Navigation.PushModalAsync(new ChangeBeltForPromotion(ref toSend, ref Participants));
        }
        private async void PopulateReceivedList(Students sender, ObservableCollection <Person> args)
        {
            AllPeople = args;
            var ParticipantsIdList = new ObservableCollection <int>(Newtonsoft.Json.JsonConvert.DeserializeObject <ObservableCollection <int> >(_bjjEvent.ParticipantsBlob));
            var BeltsIdList        = new ObservableCollection <byte>(Newtonsoft.Json.JsonConvert.DeserializeObject <ObservableCollection <byte> >(_bjjEvent.NewBeltsBlob));
            var BeltsList          = new ObservableCollection <Belt>();

            var Belts = await _connection.Table <Belt>().ToListAsync();

            foreach (var beltId in BeltsIdList)
            {
                foreach (var belt in Belts)
                {
                    if (beltId == belt.Id)
                    {
                        BeltsList.Add(belt);
                    }
                }
            }

            int i = 0;

            foreach (var Id in ParticipantsIdList)
            {
                foreach (var Person in AllPeople)
                {
                    if (Person.Id == Id)
                    {
                        PromotedPerson PersonToBePromoted = new PromotedPerson(Person, BeltsList[i]);
                        if (PersonToBePromoted.NewBelt.Id > PersonToBePromoted.Person.BeltId)
                        {
                            PersonToBePromoted.IsPromotionOK = true;
                        }
                        else
                        {
                            PersonToBePromoted.IsPromotionOK = false;
                        }
                        Participants.Add(PersonToBePromoted);
                    }
                }
                i++;
            }

            NoOfParticipants.Text = Participants.Count.ToString();
        }