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); }
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); }
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); }
public Suggestion AddSuggestion(VolunteerProject project) { Suggestion newSuggestion = new Suggestion(this, project); Matches.Add(newSuggestion); return(newSuggestion); }
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); }
public Match(Volunteer volunteer, VolunteerProject project, DateTime expire, bool?accepted = null) { this.Volunteer = volunteer; this.Project = project; this.Accepted = accepted; this.Expire = expire; SetScore(); }
public void RemoveProject(VolunteerProject project) { foreach (Match match in Matches) { if (match.Project == project) { Matches.Remove(match); break; } } }
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"); }
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; }
public Invite(Volunteer volunteer, VolunteerProject project) : base(volunteer, project) { }
public WorkRequest(Volunteer volunteer, VolunteerProject project) : base(volunteer, project) { }
public Match(Volunteer volunteer, VolunteerProject project, bool?accepted = null) : this(volunteer, project, project.Time, accepted) { }