Example #1
0
        public Match AddInvite(VolunteerProject project)
        {
            foreach (Match match in Matches)
            {
                if (match.Project == project)
                {
                    if (match.GetType() == typeof(WorkRequest))
                    {
                        match.AcceptMatch();
                        return(match);
                    }

                    if (match.GetType() == typeof(Invite))
                    {
                        return(match);
                    }
                }
            }

            Invite newInvite = new Invite(this, project);

            Matches.Add(newInvite);

            if (!string.IsNullOrEmpty(this.Email))
            {
                Mail   mail     = new Mail();
                string textbody = "You have been invited to " + project.Title + "!";
                mail.SendMail(this.Email, "Invitation", textbody);
            }

            return(newInvite);
        }
Example #2
0
        public double Calculate(VolunteerProject pos1, Volunteer pos2)
        {
            if (pos1.Location == null || pos2.Location == null)
            {
                return(1);
            }
            //Returning 1 because the javascript cannot find the locations
            //from the users, which gives our doubles the default value.
            if (pos2.Location.Lat == 0.0 && pos2.Location.Lng == 0.0)
            {
                return(1);
            }
            if (pos1.Location.Lat == 0.0 && pos1.Location.Lng == 0.0)
            {
                return(1);
            }
            double Radius = 6371; //Mean radius of the earth in kilometers

            //Finds the delta longitude and latitude of the positions.
            double dLat = ToRadians(pos2.Location.Lat - pos1.Location.Lat);
            double dLon = ToRadians(pos2.Location.Lng - pos1.Location.Lng);

            double lat1 = ToRadians(pos1.Location.Lat);
            double lat2 = ToRadians(pos2.Location.Lat);

            //Haversine Formula
            double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
                       Math.Sin(dLon / 2) * Math.Sin(dLon / 2) * Math.Cos(lat1) * Math.Cos(lat2);
            double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));

            return(Radius * c);
        }
Example #3
0
        public Match AddWorkRequest(VolunteerProject project)
        {
            foreach (Match match in Matches)
            {
                if (match.Project == project)
                {
                    if (match.GetType() == typeof(Invite))
                    {
                        match.AcceptMatch();
                        return(match);
                    }
                    if (match.GetType() == typeof(WorkRequest))
                    {
                        return(match);
                    }

                    Matches.Remove(match);
                    break;
                }
            }

            WorkRequest newWorkRequest = new WorkRequest(this, project);

            Matches.Add(newWorkRequest);

            return(newWorkRequest);
        }
Example #4
0
        public Suggestion AddSuggestion(VolunteerProject project)
        {
            Suggestion newSuggestion = new Suggestion(this, project);

            Matches.Add(newSuggestion);
            return(newSuggestion);
        }
Example #5
0
        public VolunteerProject CreateProject(string title, Location location, DateTime time, Topic topics, string description = "")
        {
            VolunteerProject newProject = new VolunteerProject(title, location, time, topics, this, description, true);

            VolunteerProjects.Add(newProject);

            return(newProject);
        }
Example #6
0
 public Match(Volunteer volunteer, VolunteerProject project, DateTime expire, bool?accepted = null)
 {
     this.Volunteer = volunteer;
     this.Project   = project;
     this.Accepted  = accepted;
     this.Expire    = expire;
     SetScore();
 }
Example #7
0
 public void RemoveProject(VolunteerProject project)
 {
     foreach (Match match in Matches)
     {
         if (match.Project == project)
         {
             Matches.Remove(match);
             break;
         }
     }
 }
Example #8
0
 public string GetStatusOfProject(VolunteerProject project)
 {
     foreach (Match match in Matches)
     {
         if (match.Project == project)
         {
             return(match.Accepted == true ? "Leave" :
                    match is Invite ? "Accept invite" :
                    match is WorkRequest ? "Work requested" :
                    match is Suggestion ? "Join suggested" :
                    "Join");
         }
     }
     return("Join");
 }
Example #9
0
 public Suggestion(Volunteer volunteer, VolunteerProject project)
     : base(volunteer, project, DateTime.Now.AddDays(1), null) //Instead of add days 1, volunteer.settings.suggestiontime
 {
     this.Project = project;
 }
Example #10
0
 public Invite(Volunteer volunteer, VolunteerProject project)
     : base(volunteer, project)
 {
 }
Example #11
0
 public WorkRequest(Volunteer volunteer, VolunteerProject project)
     : base(volunteer, project)
 {
 }
Example #12
0
 public Match(Volunteer volunteer, VolunteerProject project, bool?accepted = null)
     : this(volunteer, project, project.Time, accepted)
 {
 }