Exemplo n.º 1
0
        private void PayedUser()
        {
            Console.WriteLine("Nummer på användaren som betalat: ");
            int getNumber    = 0;
            var firstname    = "";
            var lastname     = "";
            var emailaddress = "";

            var lists   = _game.PayFee();
            var players = _game.GetPersons();

            var count = lists.Count();

            if (count == 0)
            {
                Console.WriteLine("Finns inga personer som inte har betalat");
            }
            else
            {
                foreach (var items in lists)
                {
                    Console.WriteLine($"Ange: {items.ContestNumber} Om denna person betalat: {items.FirstName} {items.LastName} med epostadressen {items.Email}");
                }

                try
                {
                    var input = Convert.ToInt32(Console.ReadLine());

                    List <Person> NewItems = new List <Person>();

                    foreach (var values in lists)
                    {
                        if (values.ContestNumber == input)
                        {
                            foreach (var number in players) //Från PayFee
                            {
                                if (getNumber < number.ContestNumber)
                                {
                                    getNumber = number.ContestNumber;
                                }

                                firstname    = values.FirstName;
                                lastname     = values.LastName;
                                emailaddress = values.Email;
                            }

                            var counting = proxy.Add(getNumber, 1);

                            var personValues  = new Person(Convert.ToInt32(counting), firstname, lastname, emailaddress);
                            var addedToMember = _game.AddPerson(personValues);
                        }

                        else
                        {
                            NewItems.Add(values);
                        }
                    }
                    //Tar bort personen från PayFee filen!
                    if (NewItems.Count > 0)
                    {
                        var returned = _game.RemoveFromFee(NewItems);
                        Console.WriteLine(returned);
                    }
                }

                catch (FormatException) //Fel format hantering
                {
                    Console.WriteLine("Du kan bara skriva in siffror.. :)");
                }
            }
        }