Exemple #1
0
        private void CreateReport(String filePath, FitnessClassList fitnessClassList)
        {
            FileStream   outFile;
            StreamWriter writer;

            outFile = new FileStream(filePath, FileMode.Create,
                                     FileAccess.Write);
            writer = new StreamWriter(outFile);

            for (int i = 0; i < fitnessClassList.Count(); i++)
            {
                FitnessClassOpportunity f = fitnessClassList.getFitnessClass(i);

                // output fitness class opportunity details and enclose these details with the xml root tags

                if (i == 0)
                {
                    writer.WriteLine("<fitnessclasses>");
                }

                writer.WriteLine(f.ToString());

                if (i == fitnessClassList.Count() - 1)
                {
                    writer.WriteLine("</fitnessclasses>");
                }
            }

            // close writer
            writer.Close();

            // close file
            outFile.Close();
        }
        public void addFitnessClass(FitnessClassOpportunity fitnessClassOpportunity)
        {
            // Make sure a class with this ID does not already exist
            foreach (FitnessClassOpportunity f in fitnessClassList)
            {
                if (f.Id == fitnessClassOpportunity.Id)
                {
                    throw new DuplicateIdException();
                }
            }

            fitnessClassList.Add(fitnessClassOpportunity);
        }
 public void removefitnessClass(FitnessClassOpportunity fitnessClassOpportunity)
 {
     fitnessClassList.Remove(fitnessClassOpportunity);
 }