Esempio n. 1
0
        static ResidentsList FilterResidentsByMoneySpent(ResidentsList residentsList)
        {
            var filteredResidents = new ResidentsList();
            var averageMoneySpent = CalculateResidentsAverageMoneySpent(residentsList);

            for (residentsList.StartOfList(); residentsList.Contains(); residentsList.NextListNode())
            {
                if (averageMoneySpent > residentsList.GetData().MoneySpent)
                {
                    filteredResidents.AddData(residentsList.GetData());
                }
            }

            return(filteredResidents);
        }
Esempio n. 2
0
        ResidentsList ReadResidentsData(string file)
        {
            var residentsList = new ResidentsList();

            using (StreamReader reader = new StreamReader(Server.MapPath(file)))
            {
                var line = reader.ReadLine();
                while (line != null)
                {
                    var values       = line.Split(' ');
                    var surname      = values[0];
                    var name         = values[1];
                    var address      = values[2];
                    var month        = values[3];
                    var utilityCode  = values[4];
                    var serviceCount = int.Parse(values[5]);
                    residentsList.AddData(new Residents(surname, name, address, month, utilityCode, serviceCount));
                    line = reader.ReadLine();
                }
            }

            return(residentsList);
        }