Ejemplo n.º 1
0
 public void ItShouldGetStudentsWithLowestGrade()
 {
     Pupil John = new Pupil("John");
     John.AddGrades(10, "Math");
     John.AddGrades(5, "Math");
     John.AddGrades(6, "Math");
     John.AddGrades(8, "Math");
     John.AddGrades(10, "Literature");
     John.AddGrades(9, "Literature");
     John.AddGrades(9, "Literature");
     John.AddGrades(8, "Literature");
     Pupil Mike = new Pupil("Mike");
     Mike.AddGrades(10, "Math");
     Mike.AddGrades(9, "Math");
     Mike.AddGrades(8, "Math");
     Mike.AddGrades(8, "Math");
     Mike.AddGrades(7, "Literature");
     Mike.AddGrades(9, "Literature");
     Mike.AddGrades(7, "Literature");
     Mike.AddGrades(8, "Literature");
     Pupil Anna = new Pupil("Anna");
     Anna.AddGrades(10, "Math");
     Anna.AddGrades(10, "Math");
     Anna.AddGrades(7, "Math");
     Anna.AddGrades(8, "Math");
     Anna.AddGrades(10, "Literature");
     Anna.AddGrades(9, "Literature");
     Anna.AddGrades(9, "Literature");
     Anna.AddGrades(10, "Literature");
     Pupil[] students = new Pupil[] { John, Mike, Anna };
     Teacher Teacher1 = new Teacher(students);
     List<Pupil> expected = new List<Pupil> { John, Mike };
     List<Pupil> actual = Teacher1.GetStudentsWithLowestGrade();
     CollectionAssert.AreEqual(expected, actual);
 }
Ejemplo n.º 2
0
        public void GetEvaluationFor_ThrowsExceptionForUnknownActivity()
        {
            Pupil p = new Pupil("ghis", 20);

            var evaluation = p.GetEvaluationFor("env dev");
            Assert.AreEqual('d', evaluation);
        }
Ejemplo n.º 3
0
        public void TestMethod1()
        {
            Pupil p = new Pupil("ghis",20);
            Activity a = new Activity("env dev", false);
            p.addActivity(a);

            p.AddEvaluation("env dev", 'd');

            var evaluation = p.GetEvaluationFor("env dev");
            Assert.AreEqual('d', evaluation);
        }
Ejemplo n.º 4
0
 public void IsShouldGetGeneralGrade()
 {
     Pupil Johnny = new Pupil("Johnny");
     Johnny.AddGrades(10, "Math");
     Johnny.AddGrades(10, "Math");
     Johnny.AddGrades(7, "Math");
     Johnny.AddGrades(8, "Math");
     Johnny.AddGrades(5, "Chemistry");
     double actual = Johnny.GetPupilGeneralGrade();
     double expected = 7;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Pupil p1 = new Pupil("Justin", 12);
            Activity a1 = new Activity("Faire ses devoir", true);
            Activity a2 = new Activity("Aider ses camarades", false);

            p1.AddActivity(a2);
            p1.AddActivity(a1);

            System.Console.Write(p1);
            System.Console.Read();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            Pupil[] pupils = new Pupil[5];

            for (int i = 0; i < 5; i++)
            {
                Console.Write("Please enter your name: ");
                String name = Console.ReadLine();

                Console.Write("Please enter your age: ");
                String age = Console.ReadLine();
                Console.Write("Please enter your gender (M/F/A/G/MAYO: ");
                String gender = Console.ReadLine();
                gender = gender.ToUpper();
                Console.Write("Please enter your house (WH/CO/WI/BE/BA): ");
                String house = Console.ReadLine();
                house = house.ToUpper();
                pupils[i].name = name;
                int ageInt;
                if (Int32.TryParse(age, out ageInt))
                { }
                else
                {
                    Console.WriteLine("Invalid Entry");
                }
                pupils[i].age = ageInt;

                switch (gender)
                {
                    case "M": { pupils[i].gender = Gender.Male; break; }
                    case "MAYO": { pupils[i].gender = Gender.Mayonnaise; break; }
                    case "F": { pupils[i].gender = Gender.Female; break; }
                    case "A": { pupils[i].gender = Gender.Agender; break; }
                    case "G": { pupils[i].gender = Gender.Genderfluid; break; }
                }
                switch (house)
                {
                    case "WH": { pupils[i].house = House.Whittle; break; }
                    case "CO": { pupils[i].house = House.Compton; break; }
                    case "WI": { pupils[i].house = House.Winterbourne; break; }
                    case "BE": { pupils[i].house = House.Berwick; break; }
                    case "BA": { pupils[i].house = House.Bassett; break; }
                }
            }

            foreach (Pupil g in pupils)
            {
                Console.WriteLine(g);
            }

            Console.ReadLine();
        }
        public Achievement(Festival festival, Discipline discipline, Pupil pupil)
        {
            if (festival == null)
                throw new ArgumentNullException(nameof(festival));
            if (discipline == null)
                throw new ArgumentNullException(nameof(discipline));
            if (pupil == null)
                throw new ArgumentNullException(nameof(pupil));

            Festival = festival;
            Discipline = discipline;
            Pupil = pupil;
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            Pupil pUn = new Pupil("Flo", 6);
            Pupil pDeux = new Pupil("Laure", 6);
            Pupil pupilGrade1 = new Pupil("John", 6);
            Activity actUn = new Activity("peinture", false);
            Activity actDeux = new Activity("bricolage", false);
            Activity actTrois = new Activity("français", true);
            Activity actQuatre = new Activity("sport", true);
            Activity actCinq = new Activity("orientation", false);
            Activity coloriage = new Activity("coloriage", true);

            pUn.AddActivity(actUn);
            pUn.AddActivity(actTrois);
            pUn.AddActivity(actCinq);
            pupilGrade1.AddActivity(coloriage);

            pupilGrade1.AddEvaluation("coloriage");
            pUn.AddEvaluation(evaluation: (char)Parametre.Eval.TresBien, title: "peinture");

            System.Console.Write(pUn);
            System.Console.Write(pUn.getEvaluationFor("peinture"));
            System.Console.ReadKey();

            System.Console.Write(pDeux);
            System.Console.ReadKey();

            List<Pupil> lstPupil = new List<Pupil>()
            {
                new Pupil("Johnatan",7),
                new Pupil("Marie",7),
                new Pupil("Max",7,2),
                new Pupil("paul",6),
                new Pupil("nat",5),
            };

            var pupilGrade1Plus6 = lstPupil.Where(pupil => pupil.Age > 6 && pupil.Grade == 1);
            //var pupilGrade1Plus6 = from pupil in lstPupil
                                  // where pupil.Age > 6 && pupil.Grade == 1
                                   //select pupil;

            if (pupilGrade1Plus6 != null)
            {
                foreach (var pupil in pupilGrade1Plus6)
                {
                    System.Console.Write(pupil);
                }
            }

            System.Console.ReadKey();
        }
Ejemplo n.º 9
0
 internal static Pupil BinarySearch(ref Pupil[] pupils, float generalGrade, int left, int right)
 {
     if (right < left) return new Pupil();
     int middle = (left + right) / 2 ;
     if (generalGrade < pupils[middle].GeneralGrade)
     {
         return BinarySearch(ref pupils, generalGrade, middle + 1, right);
     }
     else if (generalGrade > pupils[middle].GeneralGrade)
     {
         return BinarySearch(ref pupils, generalGrade, left, middle - 1);
     }
     else return pupils[middle];
 }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Console.WriteLine("How many pupils do you want to enter?");
            string x = Console.ReadLine();
            int result;
            Int32.TryParse(x, out result);
            Pupil[] pupils = new Pupil[result];

            for (int z = 0; z < result; z++)
            {
                Console.WriteLine("Enter Name: ");
                pupils[z].name = Console.ReadLine();
                Console.WriteLine("Enter Age: ");
                Int32.TryParse(Console.ReadLine(), out pupils[z].age);
                Console.WriteLine("Enter Gender (M/F/O): ");
                switch (Console.ReadLine().ToUpper())
                {

                    case "M": { pupils[z].gender = Gender.Male; break; }
                    case "F": { pupils[z].gender = Gender.Female; break; }
                    case "O": { pupils[z].gender = Gender.Other; break; }
                }
                Console.WriteLine("Enter House: (Ba/Be/Co/Wi/Wo)");
                switch (Console.ReadLine().ToUpper())
                {

                    case "Ba": { pupils[z].house = House.Bassett; break; }
                    case "Be": { pupils[z].house = House.Berwick; break; }
                    case "Co": { pupils[z].house = House.Compton; break; }
                    case "Wi": { pupils[z].house = House.Winterbourne; break; }
                    case "Wo": { pupils[z].house = House.Wootton; break; }
                }
            }
            int n = 1;
            foreach (Pupil item in pupils)
            {
                Console.WriteLine(" ");
                Console.WriteLine("Pupil " + (n) + " - ");
                Console.WriteLine("Name: " + item.name);
                Console.WriteLine("Age: " + item.age);
                Console.WriteLine("Gender: " + item.gender);
                Console.WriteLine("House: " + item.house);
                n=n+1;
            }
            Console.ReadLine();
        }
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Pupil pupil = new Pupil
            {
                FirstName = Pupil.FirstName,
                LastName  = Pupil.LastName,
            };

            _unitOfWork.PupilRepository.Add(pupil);
            _unitOfWork.SaveChanges();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 12
0
        public void ShowPupilInfo(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode.Level == 0)
            {
                HidePupilInfo();
                return;
            }

            Pupil Pupil = Pupils[(int)treeView1.SelectedNode.Tag];

            pictureBox3.Image = PeopleLargeIcons.Images[(int)Pupil.Gender + 1];
            label37.Text      = Pupil.FirstName + " " + Pupil.LastName;
            label36.Text      = "Happiness: " + Pupil.Happiness + "/1000\n\rIntelligence: " + Pupil.Intelligence + "/10\n\rMotivation: " + Pupil.Motivation + "/10";

            pictureBox3.Visible = true;
            label37.Visible     = true;
            label36.Visible     = true;
        }
Ejemplo n.º 13
0
        public void UpdatePupil(Pupil pupil)
        {
            PupilGroup oldPupil = null;

            if (pupil.PupilId != 0)
            {
                oldPupil = PupilGroups.SingleOrDefault(p => p.PupilId == pupil.PupilId);
                oldPupil.Pupil.FirstName = pupil.FirstName;
                oldPupil.Pupil.Surname   = pupil.Surname;
            }
            else
            {
                PupilGroups.Add(new PupilGroup()
                {
                    Group = this, GroupId = this.GroupId, Pupil = pupil
                });
            }
        }
Ejemplo n.º 14
0
        public void AuthenticateUnknownPupilByNickname(Pupil unknownPupil, Action authenticateUnknownPupil)
        {
            "Given an unknown pupil"
            .x(() => unknownPupil = _fixture.Create <Pupil>());

            "When I attempt to authenticate with its credentials"
            .x(()
               => authenticateUnknownPupil = ()
                                             => _pupilService.AuthenticatePupil(new AuthenticationDto
            {
                Password = unknownPupil.PupilPassword,
                Login    = unknownPupil.PupilNickname
            }));

            "Then the service should raise an exception"
            .x(()
               => authenticateUnknownPupil.Should().Throw <UnknownUserException>());
        }
Ejemplo n.º 15
0
        public async Task <IActionResult> OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Pupil pupil = new Pupil
            {
                FirstName = Pupil.FirstName,
                LastName  = Pupil.LastName,
            };

            await _unitOfWork.PupilRepository.AddAsync(pupil);

            await _unitOfWork.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            List <Subject> subjects = new List <Subject>(1);
            Subject        eng      = new Subject("English", 120, 30);
            Subject        ger      = new Subject("German", 130, 30);

            subjects.Add(eng);
            subjects.Add(ger);

            Person bob = new Pupil(1, "Bob", "Harington", 34, "USA", subjects);
            Person tim = new Teacher(1, "Tim", "Bears", 55, "Maroko", 1500, subjects);

            bob.Display();
            Console.WriteLine("\n");
            tim.Display();


            Console.ReadLine();
        }
Ejemplo n.º 17
0
        public void Update(Pupil pupil)
        {
            List <Pupil> pupils = new List <Pupil>();

            if (File.Exists(PathFile))
            {
                pupils = JsonConvert.DeserializeObject <List <Pupil> >(File.ReadAllText(PathFile));
            }

            var current = pupils.Find(e => e.Name == pupil.Name);

            if (current != null)
            {
                pupils.Remove(current);
            }

            pupils.Add(pupil);
            File.WriteAllText(PathFile, JsonConvert.SerializeObject(pupils));
        }
Ejemplo n.º 18
0
        public PupilResponse Map(Pupil pupil)
        {
            if (pupil == null)
            {
                return(null);
            }

            var pupilResponse = new PupilResponse
            {
                Id                = pupil.Id,
                Firstname         = pupil.Firstname,
                EnrolledInClasses = pupil.PupilInClass
                                    .Select(x => HelperMapper.BasicMap(x.Class)),
                EnrolledInCourses = pupil.PupilInCourse
                                    .Select(x => HelperMapper.BasicMap(x.Course))
            };

            return(pupilResponse);
        }
Ejemplo n.º 19
0
      public IHttpActionResult PutPupil(string id, [FromBody] PupilDTO pupil)
      {
          if (!ModelState.IsValid)
          {
              return(BadRequest(ModelState));
          }
          if (id != pupil.PupilId)
          {
              return(BadRequest());
          }

          Pupil savedPupil = pupilService.Update(pupil);

          if (savedPupil == null)
          {
              return(NotFound());
          }
          return(StatusCode(HttpStatusCode.NoContent));
      }
        public Achievement(Festival festival, Discipline discipline, Pupil pupil)
        {
            if (festival == null)
            {
                throw new ArgumentNullException(nameof(festival));
            }
            if (discipline == null)
            {
                throw new ArgumentNullException(nameof(discipline));
            }
            if (pupil == null)
            {
                throw new ArgumentNullException(nameof(pupil));
            }

            Festival   = festival;
            Discipline = discipline;
            Pupil      = pupil;
        }
Ejemplo n.º 21
0
        public ActionResult Delete(int id)
        {
            //Get current pupil from the database
            string url = "PupilData/FindPupil/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            //Can catch the status code (200 OK, 301 REDIRECT), etc.
            //Debug.WriteLine(response.StatusCode);
            if (response.IsSuccessStatusCode)
            {
                //Put data into player data transfer object
                Pupil SelectedPupil = response.Content.ReadAsAsync <Pupil>().Result;
                return(View(SelectedPupil));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Ejemplo n.º 22
0
        private void btnAddPupil_Click(object sender, EventArgs e)
        {
            if (listSchools.SelectedItems.Count == 0)
            {
                MessageBox.Show("No school selected.");
                return;
            }
            Pupil pupil = new Pupil();
            pupil.Name = txtPupil.Text;
            School school = (School)listSchools.SelectedItems[0].Tag;
            school.Pupils.Add(pupil);

            ListViewItem item = new ListViewItem(pupil.Name);
            item.Tag = pupil;
            listPupils.Items.Add(item);

            txtPupil.Clear();
            txtPupil.Focus();
        }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            List<Pupil> pupilList = new List<Pupil>()
            {
                new Pupil ("Ghislain", 20, 5),
                new Pupil ("Françoise", 26, 2),
                new Pupil ("Olivier", 20, 4),
                new Pupil ("Zipo", 5, 1),
                new Pupil ("Mimu", 7, 1),
                new Pupil ("Nono", 8, 1),
            };
            //var pupilGrade1Plus6 = from pupil in pupilList
            //                       where pupil.Grade == 1 && pupil.Age > 6
            //                       select pupil;
            var pupilGrade1Plus6 = pupilList.Where(pupil =>pupil.Grade ==1 && pupil.Age > 6); //Lambda expression

            if(pupilGrade1Plus6 != null)
                foreach(var pupil in pupilGrade1Plus6)
                {
                    System.Console.Write(pupil);
                    System.Console.Write("\n");
                }

            //Covariance
            List <Pupil> listPupils = new List <Pupil>()
            {
                new Pupil("AAAA", 21, "IG");
            } ;

            Activity a = new Activity("Math",false);
            Activity a1 = new Activity("Français", true);
            Activity a2 = new Activity("Langage c", false);

            Pupil p1 = new Pupil("Ghislain", 20);

            p1.addActivity(a);
            p1.addActivity(a2);
            p1.AddEvaluation("Math");

            System.Console.Write(p1);
            System.Console.Read();
        }
Ejemplo n.º 24
0
        private void btPupil_Click(object sender, EventArgs e)
        {
            Button bt = (Button)sender;

            if (tbName.Text == "" || tbAge.Text == "" || tbChinese.Text == "" || tbMath.Text == "")
            {
                MessageBox.Show("不能为空!", "警告", MessageBoxButtons.OK);
            }
            else
            {
                if (bt.Text == "中学生")
                {
                    if (tbEnglish.Text == "")
                    {
                        MessageBox.Show("英语不能为空!", "警告", MessageBoxButtons.OK);
                        return;
                    }
                }

                string name    = tbName.Text;
                int    age     = Convert.ToInt32(tbAge.Text);
                double chinese = Convert.ToDouble(tbChinese.Text);
                double math    = Convert.ToDouble(tbMath.Text);

                if (age > 0 && age <= 150 && chinese >= 0 && chinese <= 100 && math >= 0 && math <= 100)
                {
                    if (bt.Text == "中学生")
                    {
                        double english = Convert.ToDouble(tbEnglish.Text);
                        Middle middle  = new Middle(name, age, chinese, math, english);
                        tbManifest.Text += string.Format("总人数:{0},姓名:{1},中学生,平均成绩为:{2}{3}",
                                                         Middle.number, middle.Name, middle.Average(), System.Environment.NewLine);
                    }
                    else
                    {
                        Pupil pupil = new Pupil(name, age, chinese, math);
                        tbManifest.Text += string.Format("总人数:{0},姓名:{1},{2},平均成绩为:{3}{4}",
                                                         Pupil.number, pupil.Name, bt.Text, pupil.Average(), System.Environment.NewLine);
                    }
                }
            }
        }
Ejemplo n.º 25
0
        public async Task <ActionResult <Pupil> > PostPupil(Pupil pupil)
        {
            // Felder mit [Required] in der Modelklasse werden automatisch geprüft. Wurden sie
            // nicht übermittelt, so wird BadRequest() erzeugt. Darum müssen wir uns nicht
            // kümmern.
            _context.Pupil.Add(pupil);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                // Hier landet man, wenn Contraints fehlschlagen. Möchte man diese feiner
                // abprüfen, so müssen sie im Programmcode vorab geprüft werden.
                return(Conflict());
            }

            // Liefert den Inhalt des Requests GET /api/pupil/{id} und HTTP 201 (Created)
            return(CreatedAtAction(nameof(GetPupil), new { id = pupil.P_ID }, pupil));
        }
Ejemplo n.º 26
0
        public async Task <ActionResult <Pupil> > DeletePupil(long id)
        {
            Pupil pupil = await _context.Pupil.FindAsync(id);

            if (pupil == null)
            {
                return(NotFound());
            }
            _context.Pupil.Remove(pupil);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                // Es kann vorkommen, dass die Daten als FK verwendet werden.
                return(Conflict());
            }
            return(NoContent());
        }
Ejemplo n.º 27
0
        public ActionResult Edit([Bind(Include = "Pupil_Id,First_Name,Middle_Name,Surname,Pesel_Number,Legal_Guardian_Id,Birth_Date,School_Id_Card_Number,Account_Id,Class_Number")] Pupil pupil)
        {
            String accountTemp = "";

            using (MojDziennikEntities tempdb = new MojDziennikEntities())
            {
                accountTemp = tempdb.Pupil.Find(pupil.Pupil_Id).ToString();
            }
            LogManager.createlog("Edit", accountTemp);
            if (ModelState.IsValid)
            {
                db.Entry(pupil).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.Account_Id        = new SelectList(db.Account, "Account_Id", "Login", pupil.Account_Id);
            ViewBag.Legal_Guardian_Id = new SelectList(db.Legal_Guardian, "Legal_Guardian_Id", "First_Name", pupil.Legal_Guardian_Id);
            ViewBag.Class_Number      = new SelectList(db.School_Class, "Class_Number", "Profile", pupil.Class_Number);
            return(View(pupil));
        }
        public IHttpActionResult FindPupil(int id)
        {
            Pupil pupil = db.Pupils.Find(id);

            if (pupil == null)
            {
                return(NotFound());
            }
            PupilDto pupilTemp = new PupilDto
            {
                pId       = pupil.pId,
                firstName = pupil.firstName,
                lastName  = pupil.lastName,
                age       = pupil.age,
                classId   = pupil.classId,
                locId     = pupil.locId
            };

            return(Ok(pupilTemp));
        }
Ejemplo n.º 29
0
        public async Task <IActionResult> PutPupil(int id, Pupil pupil)
        {
            if (Request.Headers.GetCommaSeparatedValues("Authorization").ToList().Count < 1)
            {
                Response.StatusCode = 403;
                return(null);
            }

            string token = Request.Headers.GetCommaSeparatedValues("Authorization").ToList().ElementAt(0);

            if (UserHelpers.GetUser(token, _context).AccessLevel < (int)Permissions.Pupil)
            {
                Response.StatusCode = 403;
                return(null);
            }

            if (id != pupil.Id)
            {
                return(BadRequest());
            }

            _context.Entry(pupil).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PupilExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 30
0
        static long Benchmark(int projectNum, int ProjectSize, int pupilNum, int choiceCount, out int[] granted)
        {
            Parameter[] parameters = new Parameter[] { new ParameterInt(0) };

            Dictionary <int, Project> projects = new Dictionary <int, Project>();

            for (int i = 0; i < projectNum; i++)
            {
                Project p = new Project(i.ToString(), ProjectSize)
                {
                    Condition = new Condition(Condition.Types.Greater, parameters[0], -1)
                };
                projects.Add(i, p);
            }

            Random       random = new Random();
            List <Pupil> pupils = new List <Pupil>();

            for (int i = 0; i < pupilNum; i++)
            {
                Pupil pupil = new Pupil(i.ToString(), null, 1);
                pupil.SetParameter(parameters[0], i);
                List <Project> choices = new List <Project>(projects.Values);

                pupil.Choices = new Project[choiceCount];

                for (int c = 0; c < choiceCount; c++)
                {
                    pupil.Choices[c] = choices[random.Next(choices.Count)];
                }

                pupils.Add(pupil);
            }

            PupilProjectPlanner.PPP planner = new PupilProjectPlanner.PPP();

            System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew();
            var result = planner.Assign(projects.Values, pupils, false, out granted);

            return(watch.ElapsedMilliseconds);
        }
Ejemplo n.º 31
0
        public ActionResult Edit(int id, Pupil Pupil)//currentPupil
        {
            Debug.WriteLine(Pupil.firstName + " " + Pupil.lastName + " " + Pupil.classId + " " + Pupil.locId + " " + Pupil.pId + " " + id);

            //Update and save the current pupil
            string url = "PupilData/UpdatePupil/" + id;

            HttpContent content = new StringContent(jss.Serialize(Pupil));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync(url, content).Result;

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("Details", new { id = Pupil.pId }));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Ejemplo n.º 32
0
        public ActionResult Create(Pupil Pupil)//newPupil
        {
            Debug.WriteLine(Pupil.firstName + " " + Pupil.lastName + " " + Pupil.classId + " " + Pupil.locId + " " + Pupil.pId);

            //Add a new pupil to the database
            string      url     = "PupilData/AddPupil";
            HttpContent content = new StringContent(jss.Serialize(Pupil));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync(url, content).Result;

            if (response.IsSuccessStatusCode)
            {
                //Redirect to the PupilList
                return(RedirectToAction("PupilList"));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Ejemplo n.º 33
0
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            if (DataGrid.SelectedRows.Count == 0)
            {
                MessageBox.Show("No Row selected", "error");
            }
            else if (DataGrid.SelectedRows.Count > 1)
            {
                MessageBox.Show("There are too many rows selected. Only select one please." + "Error");
            }
            else if (DataGrid.SelectedRows.Count == 1)
            {
                int rowNum = DataGrid.SelectedRows[0].Index; //gets row selected by user

                PupilDBAccess PupilAccess = new PupilDBAccess(db);
                int           pupilNo     = int.Parse(DataGrid.Rows[rowNum].Cells[0].Value.ToString());
                Pupil         pup         = new Pupil();
                pup = PupilAccess.getPupilByPupilNo(pupilNo);
                PupilAccess.DeletePupilWithID(pup.pupilNo);
            }
        }
Ejemplo n.º 34
0
        public void Update(Pupil pupil, int school, IEnumerable <int> intrestingPrograms, IEnumerable <int> registrarionPrograms, int enterProgram)
        {
            pupil.School = session.Get <School>(school);

            if (enterProgram == -1)
            {
                pupil.EnterProgram = null;
            }
            else
            {
                pupil.EnterProgram = session.Get <AcademicProgram>(enterProgram);
            }

            pupil.IntrestingPrograms   = GetPrograms(intrestingPrograms).ToList();
            pupil.RegistrarionPrograms = GetPrograms(registrarionPrograms).ToList();

            pupil.Type = AttendeeType.Pupil;

            session.Update(pupil);
            session.Flush();
        }
Ejemplo n.º 35
0
        private void btn1_Click(object sender, EventArgs e)
        {
            PupilDBAccess      PDBAccess = new PupilDBAccess(db);
            BookingDBAccess    BDBAccess = new BookingDBAccess(db);
            InstrumentDBAccess IDBAccess = new InstrumentDBAccess(db);
            List <Pupil>       pupils    = new List <Pupil>();
            Pupil Selected = new Pupil();

            if (string.IsNullOrWhiteSpace(txtBoxID.Text))
            {
                pupils = PDBAccess.getPupilByPupilName(txtBoxName.Text);
            }

            else
            {
                Selected = PDBAccess.getPupilByPupilNo(Convert.ToInt32(txtBoxID.Text));
                pupils.Add(Selected);
            }

            CreateTableResults(pupils);
        }
Ejemplo n.º 36
0
        private static void Main(string[] args)
        {
            string headLine = $"{"KatNr",5} | {"Vorname",-20} | {"Nachname",-20} | {"Alter",5}";

            Console.WriteLine("Dynamische Schülerliste");
            for (int k = 0; k < headLine.Length; k++)
            {
                Console.Write("=");
            }
            Console.WriteLine();

            //Testdaten
            PupilList pupils = new PupilList();
            Pupil     pupil1 = new Pupil(1, "Simon", "P", 17);

            pupils.Add(pupil1);
            Pupil pupil2 = new Pupil(2, "Anna", "Lutz", 16);
            Pupil pupil3 = new Pupil(3, "Fritz", "Auer", 15);
            Pupil pupil4 = new Pupil(6, "Hans", "Huber", 14);
            Pupil pupil5 = new Pupil(5, "Moritz", "Maier", 13);

            pupils.Add(pupil2);
            pupils.Remove(pupil1);
            pupils.Add(pupil5);
            pupils.Insert(1, pupil4);
            pupils.GetAt(1);
            pupils.Sort();
            pupils.Add(pupil3);

            Console.WriteLine(headLine);
            for (int k = 0; k < headLine.Length; k++)
            {
                Console.Write("=");
            }
            Console.WriteLine();
            for (int i = 0; i < pupils.Count; i++)
            {
                Console.WriteLine($"{pupils.GetAt(i).CatalogNumber,5} | {pupils.GetAt(i).FirstName,-20} | {pupils.GetAt(i).LastName,-20} | {pupils.GetAt(i).Age,5}");
            }
        }
Ejemplo n.º 37
0
        public void AuthenticatePupilByNickname(string originalPassword, Pupil registeredPupil, AuthenticationDto pupil,
                                                PupilDto authenticatedPupil)
        {
            "Given a password"
            .x(()
               => originalPassword = _fixture.Create <string>());

            "And a pupil already registered using this password"
            .x(() =>
            {
                registeredPupil = _fixture.Create <Pupil>();

                var hashedPassword            = originalPassword.HashedWith(registeredPupil.PupilSalt);
                registeredPupil.PupilPassword = hashedPassword;

                _pupils.Add(registeredPupil);
            });

            "When a pupil connect to its account with its original password and its nickname"
            .x(()
               =>
            {
                pupil = _fixture.Build <AuthenticationDto>()
                        .With(_ => _.Login, registeredPupil.PupilNickname)
                        .With(_ => _.Password, originalPassword)
                        .Create();

                authenticatedPupil = _pupilService.AuthenticatePupil(pupil);
            });

            "Then we should retrieve the original Pupil"
            .x(() =>
            {
                authenticatedPupil.Email.Should()
                .Be(registeredPupil.PupilEmail);

                authenticatedPupil.Nickname.Should()
                .Be(registeredPupil.PupilNickname);
            });
        }
Ejemplo n.º 38
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {   // populates the labels with information about pupil
         if (DataGrid.SelectedRows.Count == 1)
         {
             BookingDBAccess BA     = new BookingDBAccess(db);
             List <Booking>  Booked = new List <Booking>();
             Booked = BA.getAllBookings();
             int           rowNum      = DataGrid.SelectedRows[0].Index;
             int           id          = int.Parse(DataGrid.Rows[rowNum].Cells[0].Value.ToString());
             PupilDBAccess pupilAccess = new PupilDBAccess(db);
             Selected          = pupilAccess.getPupilByPupilNo(id);
             lblPupilNo.Text   = Selected.PupilNo.ToString();
             lblTitle.Text     = Selected.PupilTitle;
             lblFirstName.Text = Selected.PupilFirstName;
             lblLastName.Text  = Selected.PupilLastName;
             lblDOB.Text       = Selected.PupilDOB.ToString("d/MM/yyyy");
             int    now  = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
             string date = DateTime.Now.ToShortDateString();
             int    dob  = int.Parse(Selected.PupilDOB.ToString("yyyyMMdd"));
             int    age  = (now - dob) / 10000;
             lblAge.Text = age.ToString();
             //fix this to autoNumber
             lblBookingNo.Text = Convert.ToString(Booked[Booked.Count() - 1].bookingNo + 1);
             timer1.Start();
             lblDate.Text      = date;
             groupBox4.Enabled = false;
             groupBox5.Enabled = false;
             groupBox6.Enabled = false;
             groupBox1.Enabled = true;
             groupBox2.Enabled = true;
             groupBox3.Enabled = true;
         }
     }
     catch (NullReferenceException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public PupilsListControl()
        {
            InitializeComponent();

            var address = new Address { Location="Location", PostalCode="123", Street="Street", HouseNumber="123" };
            var teacher = new Teacher() { Address = address, BirthDate = DateTime.Now, FirstName = "FirstName", LastName = "LastName" };

            var pupils = new Pupil[10];
            for (int i = 0; i < pupils.Length; i++)
            {
                pupils[i] = new Pupil()
                {
                    Address = address,
                    FirstName = "Hans" + i.ToString(),
                    LastName = "Wurst" + i.ToString(),
                    BirthDate = DateTime.Now.Subtract(TimeSpan.FromDays(10 * 365)),
                    Class = "@"
                };
            }

            DataContext = new PupilsListViewModel(pupils);
        }
Ejemplo n.º 40
0
            public ClassRoom(Pupil p1, Pupil p2, Pupil p3, Pupil p4)
            {
                p1.Study();
                p1.Read();
                p1.Write();
                p1.Relax();

                p2.Study();
                p2.Read();
                p2.Write();
                p2.Relax();

                p3.Study();
                p3.Read();
                p3.Write();
                p3.Relax();

                p4.Study();
                p4.Read();
                p4.Write();
                p4.Relax();
            }
Ejemplo n.º 41
0
        private void btnAddPupil_Click(object sender, EventArgs e)
        {
            if (listSchools.SelectedItems.Count == 0)
            {
                MessageBox.Show("No school selected.");
                return;
            }
            Pupil pupil = new Pupil();

            pupil.Name = txtPupil.Text;
            School school = (School)listSchools.SelectedItems[0].Tag;

            school.Pupils.Add(pupil);

            ListViewItem item = new ListViewItem(pupil.Name);

            item.Tag = pupil;
            listPupils.Items.Add(item);

            txtPupil.Clear();
            txtPupil.Focus();
        }
Ejemplo n.º 42
0
            public ClassRoom(Pupil p1 , Pupil p2 , Pupil p3 , Pupil p4)
            {
                p1.Study();
                p1.Read();
                p1.Write();
                p1.Relax();

                p2.Study();
                p2.Read();
                p2.Write();
                p2.Relax();

                p3.Study();
                p3.Read();
                p3.Write();
                p3.Relax();

                p4.Study();
                p4.Read();
                p4.Write();
                p4.Relax();
            }
Ejemplo n.º 43
0
        private void btn1_Click(object sender, EventArgs e)
        {
            //Searches pupil by either pupilNo or LastName
            PupilDBAccess pupilAccess = new PupilDBAccess(db);
            List <Pupil>  pupils      = new List <Pupil>();

            if (string.IsNullOrWhiteSpace(PupilNotxt.Text))
            {
                pupils = pupilAccess.getPupilByPupilName(Nametxt.Text);
            }
            else
            {
                Selected = pupilAccess.getPupilByPupilNo(Convert.ToInt32(PupilNotxt.Text));
                pupils.Add(Selected);
            }
            // Creates table with pupil information
            table = new DataTable();
            table.Columns.Add("PupilNo");
            table.Columns.Add("First Name");
            table.Columns.Add("Last Name");
            addpupil(pupils);
        }
Ejemplo n.º 44
0
        /// <summary>
        /// Сохранить / обновить данные об ученике
        /// </summary>
        /// <param name="pupil"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task <Dto.PupilInfo> SavePupilInfo(Dto.PupilInfo pupil, int userId)
        {
            Pupil domainPupil = _Convert(pupil);

            domainPupil.PriceList = new Dictionary <LessonDuration, decimal>();
            if (pupil.OneHourPrice != null)
            {
                domainPupil.PriceList.Add(LessonDuration.OneHour, pupil.OneHourPrice.Value);
            }
            if (pupil.OneAndHalfPrice != null)
            {
                domainPupil.PriceList.Add(LessonDuration.OneAndHalf, pupil.OneAndHalfPrice.Value);
            }
            if (pupil.TwoHourPrice != null)
            {
                domainPupil.PriceList.Add(LessonDuration.TwoHour, pupil.TwoHourPrice.Value);
            }
            domainPupil.UserId = userId;
            domainPupil        = await _pupilDomainService.SavePupil(domainPupil);

            return(_Convert(domainPupil));
        }
Ejemplo n.º 45
0
        public void TestDeepClone_BasicTypes()
        {
            /*
            * Test primitive types + array type.
            */
            var pupil1 = new Pupil(1, "A", Gender.Male, new DateTime(2015, 01, 01));
            var course1 = new Course {Id = 1, Name = "C#"};

            course1.Pupils = new Pupil[] {pupil1};
            pupil1.Course = course1;

            var clonePupil1= pupil1.DeepClone();
            Assert.NotEqual(clonePupil1, pupil1);
            Assert.NotSame(clonePupil1, pupil1);
            Assert.True(Pupil.ValueEqual(pupil1, clonePupil1));

            var cloneCourse1 = course1.DeepClone();
            Assert.NotEqual(cloneCourse1, course1);
            Assert.NotSame(cloneCourse1, course1);

            Assert.NotEqual(cloneCourse1.Pupils, course1.Pupils);
            Assert.NotSame(cloneCourse1.Pupils, course1.Pupils);

            Assert.NotEqual(cloneCourse1.Pupils[0], course1.Pupils[0]);
            Assert.NotSame(cloneCourse1.Pupils[0], course1.Pupils[0]);
            Assert.True(Pupil.ValueEqual(cloneCourse1.Pupils[0], course1.Pupils[0]));

            Assert.Equal(course1.Pupils[0], pupil1);
            Assert.Same(course1.Pupils[0], pupil1);
            Assert.True(Pupil.ValueEqual(course1.Pupils[0], pupil1));
            Assert.NotEqual(cloneCourse1.Pupils[0], pupil1);
            Assert.NotSame(cloneCourse1.Pupils[0], pupil1);
            Assert.True(Pupil.ValueEqual(cloneCourse1.Pupils[0], pupil1));

            Assert.Same(course1.Pupils[0].Course, course1);
            Assert.NotSame(course1.Pupils[0].Course, cloneCourse1);
            Assert.Same(cloneCourse1.Pupils[0].Course, cloneCourse1);
        }
Ejemplo n.º 46
0
        public static void QuikSortThreeWay(Pupil[] inputArray, int left, int right)
        {
            if (right <= left) return;

            int leftEnd = left;
            int rightEnd = right;
            int position = left + 1;
            float pivot = inputArray[leftEnd].GeneralGrade;

            while (position <= rightEnd)
            {
                if (inputArray[position].GeneralGrade > pivot)
                {
                    SwapPupil(inputArray, position++, leftEnd++);
                }
                else if (pivot > inputArray[position].GeneralGrade)
                {
                    SwapPupil(inputArray, position, rightEnd--);
                }
                else position++;
            }
            QuikSortThreeWay(inputArray, left, leftEnd - 1);
            QuikSortThreeWay(inputArray, rightEnd + 1, right);
        }
Ejemplo n.º 47
0
 public Teacher(Pupil[] students)
 {
     this.students = students;
 }
Ejemplo n.º 48
0
 private static void SwapPupil(Pupil[] pupils, int firstIndex, int secondIndex)
 {
     Pupil temp = pupils[firstIndex];
     pupils[firstIndex] = pupils[secondIndex];
     pupils[secondIndex] = temp;
 }
Ejemplo n.º 49
0
        static void Main(string[] args)
        {
            Pupil p1 = new Pupil("Quentin", 10);
            Activity a1 = new Activity("Francais", true);
            Activity a2 = new Activity("Math", true);
            Activity a3 = new Activity("Anglais", false);
            Activity a4 = new Activity("Gym", false);
            Activity a5 = new Activity("Sciences", true);

            //p1.AddActivity(a1);
            //p1.AddActivity(a2);
            //p1.AddActivity(a3);
            //p1.AddActivity(a4);
            //p1.AddActivity(a5);

            p1.AddActivity("Math");
            p1.AddActivity("Francais");

            System.Console.Write(p1);

            p1.AddEvaluation("Francais");
            p1.AddEvaluation(evaluation: 'T', title: "Math");
            p1.AddEvaluation("Anglais", 'R');

            List <Pupil> listPupils = new List<Pupil>()
            {
                new Pupil("Mathieu", 11),
                new Pupil("Marie", 12, 5),
                new Pupil("Sophie", 14, 3),
                new Pupil("Maxime", 19, 4),
                new Pupil("Justine", 20),
                new Pupil("Antoine", 18, 3),
                new Pupil("Georges", 18, 7),
                new Pupil("Adam", 12, 5)
            };

            /*
            var pupilGrade1Plus6 = from pupil in listPupils
                                   where pupil.Grade == 1 && pupil.Age > 6
                                   select pupil;
            */

            //Expression lambda
                var pupilGrade1Plus6 = listPupils.Where(pupil => pupil.Grade == 1 && pupil.Age > 6);
            //

                Debug.WriteLine(pupilGrade1Plus6);

            if (pupilGrade1Plus6 != null)
            {
                System.Console.Write("\n\n\nListe des enfants de premiere annee qui ont plus de 6 ans:\n");
                foreach (var pupil in pupilGrade1Plus6)
                {
                    System.Console.Write(pupil+"\n");
                }
            }

            System.Console.WriteLine();
            System.Console.WriteLine();

            List<Person> listPersons = new List<Person>()
            {
                new Person("Albert", 13),
                new Person("Bernard", 15),
                new Person("Chantal", 17)
            };

            var listFusion = listPersons.Union(listPupils);
            foreach (var pupil in listFusion)
            {
                System.Console.Write(pupil + "\n");
            }

            List<Pupil> listPupilsDuplicated = new List<Pupil>()
            {
                new Pupil("Quentin", 21),
                new Pupil("Maxime", 19),
                new Pupil("Marie", 14),
                new Pupil("Quentin", 21),
                new Pupil("Mathieu", 18),
                new Pupil("Quentin", 21)
            };

            IEnumerable<Pupil> listPupilsNotDuplicated = listPupilsDuplicated.Distinct<Pupil>(new PersonComparer());

            System.Console.WriteLine();
            System.Console.WriteLine();
            System.Console.Write(listPupilsNotDuplicated.Count());

            System.Console.Read();
        }
Ejemplo n.º 50
0
            public ClassRoom(Pupil p1, Pupil p2)
            {
                p1.Study();
                p1.Read();
                p1.Write();
                p1.Relax();

                p2.Study();
                p2.Read();
                p2.Write();
                p2.Relax();
            }
Ejemplo n.º 51
0
 internal static string GetPupilWithGrades(Pupil[] pupils, float grade)
 {
     uint maxCount = 0;
     int maxPosition = GetMaxGradeCount(pupils, pupils.Length - 1, grade, ref maxCount);
     return pupils[maxPosition].Name;
 }
Ejemplo n.º 52
0
        public void ItShouldSortStudentsByGrade()
        {
            Pupil John = new Pupil("John");
            John.AddGrades(10, "Math");
            John.AddGrades(5, "Math");
            John.AddGrades(6, "Math");
            John.AddGrades(8, "Math");
            John.AddGrades(10, "Literature");
            John.AddGrades(9, "Literature");
            John.AddGrades(9, "Literature");
            John.AddGrades(8, "Literature");
            Pupil Mike = new Pupil("Mike");
            Mike.AddGrades(10, "Math");
            Mike.AddGrades(9, "Math");
            Mike.AddGrades(8, "Math");
            Mike.AddGrades(8, "Math");
            Mike.AddGrades(7, "Literature");
            Mike.AddGrades(9, "Literature");
            Mike.AddGrades(7, "Literature");
            Mike.AddGrades(8, "Literature");
            Pupil Anna = new Pupil("Anna");
            Anna.AddGrades(10, "Math");
            Anna.AddGrades(10, "Math");
            Anna.AddGrades(7, "Math");
            Anna.AddGrades(8, "Math");
            Anna.AddGrades(10, "Literature");
            Anna.AddGrades(9, "Literature");
            Anna.AddGrades(9, "Literature");
            Anna.AddGrades(10, "Literature");
            Pupil[] students = new Pupil[] { John, Mike, Anna };
            Teacher Teacher1 = new Teacher(students);
            Teacher1.SortStudentsByGrade();
            string[] actual = new string[3];
            for (int i = 0; i < Teacher1.GetNumberOfStudents(); i++)
                actual[i] = Teacher1.GetStudent(i).GetName();

            string[] expected = { "John", "Mike", "Anna" };
            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 53
0
        public void ItShouldSortStudents()
        {
            Pupil[] Pupils = new Pupil[4];
            Pupils[0] = new Pupil("Jim");
            Pupils[1] = new Pupil("Bob");
            Pupils[2] = new Pupil("Michelle");
            Pupils[3] = new Pupil("Anna");
            Teacher Teacher1 = new Teacher(Pupils);
            Teacher1.SortStudents();
            string[] actual = new string[4];
            for (int i = 0; i < Teacher1.GetNumberOfStudents(); i++)
                actual[i] = Pupils[i].GetName();

            string[] expected = { "Anna", "Bob", "Jim", "Michelle" };

            CollectionAssert.AreEqual(expected, actual);
        }
 public PupilDataViewModel(Pupil pupil = null)
     : base(pupil = pupil ?? new Pupil())
 {
     _pupil = pupil;
 }
Ejemplo n.º 55
0
        static void Main(string[] args)
        {
            List <Pupil>lstPupils = new List <Pupil>()
            {
                new Pupil("e1", 8),
                new Pupil("e2", 7),
                new Pupil("e3", 1),
                new Pupil("e4", 12),
                new Pupil("e5", 9),
                new Pupil("e6", 10),
                new Pupil("e7", 1),
                new Pupil("e8", 2),
                new Pupil("e9", 13),
                new Pupil("e10", 14),
            };

            Pupil etu01 = new Pupil("e1", 3);
            etu01.AddActivity(new Activity("fr", true));
            etu01.AddActivity(new Activity("grgtr", false));
            etu01.AddEvaluation("fr", 'd');

             Pupil etu02 = new Pupil("e2", 8);
             etu02.AddActivity(new Activity("fr", true));
             etu02.AddActivity(new Activity("grgtr", false));
             etu02.AddEvaluation("fr", 'd');

             Pupil etu03 = new Pupil("e3", 5);
             etu03.AddActivity(new Activity("fr", true));
             etu03.AddActivity(new Activity("grgtr", false));
             etu03.AddEvaluation("fr", 'd');

             Pupil etu04 = new Pupil("e4", 6);
             etu04.AddActivity(new Activity("fr", true));
             etu04.AddActivity(new Activity("grgtr", false));
             etu04.AddEvaluation("fr", 'd');

             Pupil etu05 = new Pupil("e5", 8);
             etu05.AddActivity(new Activity("fr", true));
             etu05.AddActivity(new Activity("grgtr", false));
             etu05.AddEvaluation("fr", 'd');

             Pupil etu06 = new Pupil("e6", 8);
             etu06.AddActivity(new Activity("fr", true));
             etu06.AddActivity(new Activity("grgtr", false));
             etu06.AddEvaluation("fr", 'd');

             var pupilGrade1Plus6 = lstPupils.Where(pupil => pupil.Age >= 6);
                /*from pupil in lstPupils
                                   where pupil.Age>6
                                   select pupil;*/

             /*if(pupilGrade1Plus6 != null)
                foreach (var pupil in pupilGrade1Plus6)
                {
                    System.Console.Write(pupil);
                    System.Console.Read();
                }*/

            List<Person> lstPerson = new List<Person>() {
                new Pupil("e1", 8),
                new Pupil("e2", 7),
                new Pupil("e3", 1),
                new Pupil("e4", 12),
                new Pupil("e5", 9),
                new Pupil("e6", 10),
                new Pupil("Barnabé", 82),
            };
            List<Person> lstFusion = new List<Person>() { };
            var pupilDiff = lstPupils.Where(pupil => lstPerson.Contains(pupil));

            var fusion = lstPerson.Concat(pupilDiff);

            if (fusion != null)
                foreach (var person in fusion)
                {
                    System.Console.Write(person);
                    System.Console.Read();
                }
        }
Ejemplo n.º 56
0
 public int CompareByGrade(Pupil otherPupil)
 {
     return this.GetPupilGeneralGrade().CompareTo(otherPupil.GetPupilGeneralGrade());
 }
Ejemplo n.º 57
0
 private static string[] GetPupilsNames(Pupil[] pupils)
 {
     string[] pupilNames = new string[pupils.Length];
     for (uint i = 0; i < pupils.Length; i++)
     {
         pupilNames[i] = pupils[i].Name;
     }
     return pupilNames;
 }
Ejemplo n.º 58
0
 public static bool ValueEqual(Pupil left, Pupil right)
 {
     return left.Id == right.Id
            && left.Name == right.Name
            && left.Gender == right.Gender
            && left.Birthday == right.Birthday;
 }
        public static Achievement GetAchievement(SportsFestivalManagerContext connection, Festival festival, Discipline discipline, Pupil pupil)
        {
            var achievement = connection.Achievements.FirstOrDefault(x => x.FestivalId == festival.Id && x.DisciplineId == discipline.Id && x.PupilId == pupil.Id);

            if (achievement == null)
                connection.Achievements.Add(achievement = new Achievement(festival, discipline, pupil));

            return achievement;
        }
Ejemplo n.º 60
0
 public int CompareByName(Pupil otherPupil)
 {
     return this.name.CompareTo(otherPupil.name);
 }