コード例 #1
0
        public ActionResult Edit(Volunteer volunteer)
        {
            //Topic tmp = new Topic();
            //ViewBag.Topics = tmp.GetValidTopics();
            Volunteer currentUser = GetCurrentUser();

            if (ModelState.IsValid && currentUser != null)
            {
                currentUser.Name                 = volunteer.Name;
                currentUser.Email                = volunteer.Email;
                currentUser.Location             = volunteer.Location;
                currentUser.VolunteerPreferences = volunteer.VolunteerPreferences;

                foreach (VolunteerProject project in db.VolunteerProjects.Include("ProjectTopics"))
                {
                    if (volunteer.VolunteerPreferences.CompareTopics(project.ProjectTopics) > 0)
                    {
                        currentUser.AddSuggestion(project);
                    }
                }

                db.Entry(currentUser).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(volunteer));
        }
コード例 #2
0
ファイル: VolunteerTest.cs プロジェクト: bossen/P3-Program
        public void TestSortMatches()
        {
            //Arrange
            Volunteer        v           = (Utility.GetVolunteer());
            VolunteerProject vp          = (Utility.GetVolunteerProject());
            Suggestion       suggestion1 = v.AddSuggestion(vp);

            //Act
            List <Match> result = v.GetSortMatches().ToList();

            //Assert
            CollectionAssert.Contains(result, suggestion1);
        }
コード例 #3
0
ファイル: VolunteerTest.cs プロジェクト: bossen/P3-Program
        public void TestSuggestion()
        {
            Volunteer        v  = (Utility.GetVolunteer());
            VolunteerProject vp = (Utility.GetVolunteerProject());

            Suggestion Expected = new Suggestion();

            Expected.Volunteer = v;
            Suggestion output = v.AddSuggestion(vp);

            Assert.AreEqual(Expected.Volunteer, output.Volunteer);

            Expected.Project = vp;
            Assert.AreEqual(Expected.Project, output.Project);
        }