Ejemplo n.º 1
0
        private async void txtRemoveSearch_Click(object sender, EventArgs e)
        {
            MongoRead      read    = new MongoRead();
            FighterProfile fighter = null;

            try
            {
                fighter = await read.getFighter(txtremoveFirstName.Text, txtremoveLastName.Text);

                delete_id = fighter._id;
            }
            catch (Exception ex)
            {
                //No Error Message Needed
            }


            if (delete_id != null)
            {
                txtRemoveName.Text        = fighter.Name.ToString();
                txtRemoveNickName.Text    = fighter.Nickname.ToString();
                txtRemoveheight.Text      = fighter.Height.ToString();
                txtRemoveFightStyle.Text  = fighter.FightStyle.Style.ToString();
                txtRemoveWeightClass.Text = fighter.WeightClass.ToString();
                txtRemoveAge.Text         = fighter.Age.ToString();
                txtRemoveDraws.Text       = fighter.WinLossRecord.Draws.ToString();
                txtRemoveWins.Text        = fighter.WinLossRecord.Wins.ToString();
                txtRemoveLosses.Text      = fighter.WinLossRecord.Losses.ToString();
                txtRemoveWeightClass.Text = fighter.WeightClass.ToString();
                txtUpdateWeight.Text      = fighter.Weight.ToString();
            }
        }
Ejemplo n.º 2
0
        private void BtnAddFigther_Click(object sender, EventArgs e)
        {
            MongoAdd add = new MongoAdd();

            try
            {
                FighterProfile fighter = new FighterProfile()
                {
                    Name          = txtName.Text.ToString(),
                    Age           = Convert.ToInt32(txtAge.Text.ToString()),
                    WinLossRecord = new FightRecord()
                    {
                        Wins   = Convert.ToInt32(txtWins.Text.ToString()),
                        Losses = Convert.ToInt32(txtLosses.Text.ToString()),
                        Draws  = Convert.ToInt32(txtDraws.Text.ToString()),
                    },
                    Nickname   = txtNickName.Text,
                    Height     = Convert.ToDouble(txtHeight.Text.ToString()),
                    Weight     = Convert.ToDouble(txtWeight.Text.ToString()),
                    FightStyle = new FightStyle()
                    {
                        Style = txtFightStye.Text.ToString()
                    },
                    WeightClass = txtWeightClass.Text
                };


                add.AddFighter(fighter);
            }catch (Exception ex)
            {
                MessageBox.Show("Please ensure all fields are filled in!");
            }
        }
Ejemplo n.º 3
0
        private void btnUpdateFighter_Click(object sender, EventArgs e)
        {
            MongoUpdate update = new MongoUpdate();


            try
            {
                FighterProfile fighter = new FighterProfile()
                {
                    _id           = update_id,
                    Name          = txtUpdateName.Text.ToString(),
                    Age           = Convert.ToInt32(txtUpdateAge.Text.ToString()),
                    WinLossRecord = new FightRecord()
                    {
                        Wins   = Convert.ToInt32(txtUpdateWins.Text.ToString()),
                        Losses = Convert.ToInt32(txtUpdateLosses.Text.ToString()),
                        Draws  = Convert.ToInt32(txtUpdateDraws.Text.ToString()),
                    },
                    Nickname   = txtUpdateNickName.Text,
                    Height     = Convert.ToDouble(txtUpdateHeight.Text.ToString()),
                    Weight     = Convert.ToDouble(txtUpdateWeight.Text.ToString()),
                    FightStyle = new FightStyle()
                    {
                        Style = txtUpdateFightStyle.Text.ToString()
                    },
                    WeightClass = txtUpdateWeightClass.Text
                };


                update.updateFighter(fighter);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please ensure all fields are filled in!");
            }
        }