private ProjectDetailModel PrepareProjectDetailModel(Project project, bool prepareComments = true) { if (project == null) throw new ArgumentNullException("project"); var model = new ProjectDetailModel { CurrentUser = _workContext.CurrentUser.ToModel(), Project = project.ToModel() }; if (prepareComments) { var comments = project.Comments.OrderBy(x => x.CreatedDate); foreach (var comment in comments) model.Project.Comments.Add(comment.ToModel()); } foreach (var complaintType in _moderationQueueService.GetAllCommentComplaintTypes()) model.CommentComplaintTypes.Add(new SelectListItem { Text = complaintType.Value, Value = complaintType.Key.ToString() }); foreach (var complaintType in _moderationQueueService.GetAllProjectComplaintTypes()) model.ProjectComplaintTypes.Add(new SelectListItem { Text = complaintType.Value, Value = complaintType.Key.ToString() }); string descriptionDate = ""; if (model.Project.StartDate != null) { string descriptionTime = _webHelper.DateTimeFormat("H:mmTT", model.Project.StartDate.Value); if (model.Project.EndDate != null && model.Project.EndDate.Value.Subtract(model.Project.StartDate.Value).Days < 1) descriptionTime += " to " + _webHelper.DateTimeFormat("H:mmTT", model.Project.EndDate.Value); descriptionDate = string.Format(" on {0} from {1}", _webHelper.DateTimeFormat("d~ MMMM", model.Project.StartDate.Value), descriptionTime); } model.MetaTitle = model.Project.Name + " - #WeWillGather"; model.MetaDescription = string.Format("Volunteer now and join the '{0}' project taking place{1}. Organised with #WeWillGather.", model.Project.Name, descriptionDate); return model; }
private ProjectModel PrepareListProjectModel(Project project) { var model = project.ToModel(); model.Actions.Add(new ModelActionLink { Alt = "Edit", Icon = Url.Content("~/Areas/Admin/Content/images/icon-edit.png"), Target = Url.Action("edit", new { id = project.Id }) }); model.Actions.Add(new DeleteActionLink(project.Id, Search, Page)); return model; }
public static Project ToEntity(this ProjectModel model) { if (model == null) return null; var entity = new Project { Categories = model.Categories.Select(ToEntity).ToList(), ChildFriendly = model.ChildFriendly, CreatedBy = model.CreatedById, CreatedDate = model.CreatedDate, EmailAddress = model.EmailAddress.StripHtml(), EmailDisclosureId = model.EmailDisclosureId, EndDate = model.EndDate, Equipment = model.Equipment.StripHtml(), GettingThere = model.GettingThere.StripHtml(), Id = model.Id, IsRecurring = model.IsRecurring, LastModeratorApprovalBy = model.LastModeratorApprovalBy, LastModeratorApprovalDate = model.LastModeratorApprovalDate, LastModifiedBy = model.LastModifiedBy, LastModifiedDate = model.LastModifiedDate, Latitude = model.Latitude, Locations = model.Locations.Select(ToEntity).ToList(), Longitude = model.Longitude, Name = model.Name.StripHtml(), NumberOfVolunteers = model.NumberOfVolunteers, Objective = model.Objective.StripHtml(), Owners = model.Owners.Select(ToEntity).ToList(), Recurrence = model.Recurrence, RecurrenceInterval = model.RecurrenceInterval, RecurrenceIntervalId = model.RecurrenceIntervalId, Skills = model.Skills.StripHtml(), StartDate = model.StartDate, Status = model.Status, StatusId = model.StatusId, Telephone = model.Telephone.StripHtml(), TelephoneDisclosureId = model.TelephoneDisclosureId, Volunteers = model.Volunteers.Select(ToEntity).ToList(), VolunteerBenefits = model.VolunteerBenefits.StripHtml(), Website = model.Website.StripHtml(), WebsiteDisclosureId = model.WebsiteDisclosureId }; return entity; }
public static Project ToEntity(this ProjectModel model, Project entity) { if (model == null || entity == null) return null; entity.ChildFriendly = model.ChildFriendly; entity.CreatedBy = model.CreatedById; entity.EmailAddress = model.EmailAddress.StripHtml(); entity.EmailDisclosureId = model.EmailDisclosureId; entity.EndDate = model.EndDate; entity.Equipment = model.Equipment.StripHtml(); entity.GettingThere = model.GettingThere.StripHtml(); entity.Id = model.Id; entity.IsRecurring = model.IsRecurring; entity.LastModeratorApprovalBy = model.LastModeratorApprovalBy; entity.LastModeratorApprovalDate = model.LastModeratorApprovalDate; entity.LastModifiedBy = model.LastModifiedBy; entity.LastModifiedDate = model.LastModifiedDate; entity.Latitude = model.Latitude; entity.Longitude = model.Longitude; entity.Name = model.Name.StripHtml(); entity.NumberOfVolunteers = model.NumberOfVolunteers; entity.Objective = model.Objective.StripHtml(); entity.Recurrence = model.Recurrence; entity.RecurrenceInterval = model.RecurrenceInterval; entity.RecurrenceIntervalId = model.RecurrenceIntervalId; entity.Skills = model.Skills.StripHtml(); entity.StartDate = model.StartDate; entity.Status = model.Status; entity.StatusId = model.StatusId; entity.Telephone = model.Telephone.StripHtml(); entity.TelephoneDisclosureId = model.TelephoneDisclosureId; entity.VolunteerBenefits = model.VolunteerBenefits.StripHtml(); entity.Website = model.Website.StripHtml(); entity.WebsiteDisclosureId = model.WebsiteDisclosureId; return entity; }
/// <summary> /// Insert a project for twitter, recreates the object due to context issues /// </summary> /// <param name="postcode">Postcode of the project</param> /// <param name="name">Name of the project</param> /// <param name="twitterProfile">Twitter profile name</param> /// <returns>Id of new project</returns> public int InsertTwitterProject(string postcode, string name, string twitterProfile) { decimal latitude = 999; decimal longitude = 999; Location location = null; if (!string.IsNullOrEmpty(postcode)) { _geolocationService.GetLatLng(postcode, out latitude, out longitude); location = _geolocationService.GetLocationFromLatLng(latitude, longitude); } var twitterProject = new Project { CreatedDate = DateTime.Now, LastModifiedDate = DateTime.Now, Name = name.Replace(" ", " ").Trim(), Latitude = latitude, Longitude = longitude, StatusId = (int)ProjectStatus.Draft, TwitterProfile = twitterProfile }; // Insert the entity _projectRepository.Insert(twitterProject); if (location != null) { // Add all the locations to the project entity twitterProject.Locations.Add(new ProjectLocation { LocationId = location.Id, Primary = true, ProjectId = twitterProject.Id }); var parent = location.ParentLocation; while (parent != null) { twitterProject.Locations.Add(new ProjectLocation { LocationId = parent.Id, Primary = false, ProjectId = twitterProject.Id }); parent = parent.ParentLocation; } // Update the entity _projectRepository.Update(twitterProject); } return twitterProject.Id; }
/// <summary> /// Updates the project /// </summary> /// <param name="project">Project</param> /// <param name="setLastModifiedBy"> </param> public void UpdateProject(Project project, bool setLastModifiedBy = true) { if (project == null) throw new ArgumentNullException("project"); if (setLastModifiedBy) { project.LastModifiedBy = _workContext.CurrentUser != null ? _workContext.CurrentUser.Id : 0; project.LastModifiedDate = DateTime.Now; } _projectRepository.Update(project); }
/// <summary> /// Inserts a moderation project withdrawal item /// </summary> /// <param name="project">Project object requesting withdrawal</param> /// <param name="reason">Reason for the project withdrawal</param> public void InsertModerationQueueProjectWithdrawal(Project project, string reason = null) { if (project == null) throw new ArgumentNullException("project"); if (reason == null) reason = ""; var productWithdrawal = GetProjectWithdrawalByProductId(project.Id); if (productWithdrawal != null) return; var withdrawal = new ProjectWithdrawal { Project = project, Reason = reason, ModerationQueue = new ModerationQueue { RequestType = ModerationRequestType.ProjectWithdrawal, StatusType = ModerationStatusType.Open, CreatedDate = DateTime.Now, CreatedBy = _workContext.CurrentUser.Id } }; _moderationQueueProjectWithdrawalRepository.Insert(withdrawal); }
/// <summary> /// Project starting message (Called from scheduled task running on a thread) /// </summary> /// <param name="project">the project to update</param> public void ProjectStartingMessage(Project project) { if (project == null) throw new ArgumentNullException("project"); string messageUrl = MessageUrl(); string projectUrl = ProjectUrl(project.Id); // Send a message to the project owners foreach (var message in project.Owners.Select(owner => new MessageQueue { Priority = 10, User = owner })) { message.Subject = _siteSettings.TwitterHashTag + " - " + project.Name + " : The action you setup is tomorrow"; message.ShortBody = "The action you setup is tomorrow " + projectUrl; message.Body = WrapStringInHtml("The good thing you are helping to organise is just around the corner, \"" + project.Name + "\" is starting on " + project.StartDate) + WrapStringInHtml(BuildLink(projectUrl)); InsertMessageQueue(message); } // We send a different message to any volunteer who isn't already a product owner. var volunteers = project.Volunteers.Where(volunteer => project.Owners.All(x => x.Id != volunteer.Id)).ToList(); if (volunteers.Count > 0) { foreach (var message in volunteers.Select(user => new MessageQueue { Priority = 20, User = user })) { message.Subject = _siteSettings.TwitterHashTag + " - " + project.Name + " : The action you joined is tomorrow"; message.ShortBody = "The action you joined is tomorrow " + messageUrl; message.Body = WrapStringInHtml("The good thing you signed up for is just around the corner, \"" + project.Name + "\" is starting on " + project.StartDate) + WrapStringInHtml(BuildLink(projectUrl)); InsertMessageQueue(message); } } }
/// <summary> /// Inserts a moderation project withdrawal item /// </summary> /// <param name="project">Project object requesting withdrawal</param> /// <param name="changeProject">Change project</param> public void InsertModerationQueueProjectChange(Project project, Project changeProject) { if (project == null) throw new ArgumentNullException("project"); if (changeProject == null) throw new ArgumentNullException("project"); var withdrawal = new ProjectChangeRequest { ParentProject = project, ChangeProject = changeProject, ModerationQueue = new ModerationQueue { RequestType = ModerationRequestType.ProjectChange, StatusType = ModerationStatusType.Open, CreatedDate = DateTime.Now, CreatedBy = _workContext.CurrentUser.Id } }; _moderationQueueProjectChangeRequestRepository.Insert(withdrawal); }
/// <summary> /// Inserts a moderation projectitem /// </summary> /// <param name="project">Project object requesting moderation</param> /// <param name="reason">string of the reason</param> /// <param name="type">ProjectComplaintType</param> public void InsertModerationQueueProjectModeration(Project project, string reason, ProjectComplaintType type) { if (project == null) throw new ArgumentNullException("project"); var moderation = new ProjectModeration { Reason = reason, ComplaintType = type, Project = project, ModerationQueue = new ModerationQueue { RequestType = ModerationRequestType.ProjectModeration, StatusType = ModerationStatusType.Open, CreatedDate = DateTime.Now, CreatedBy = _workContext.CurrentUser.Id } }; _moderationQueueProjectModerationRepository.Insert(moderation); }
/// <summary> /// Inserts a moderation project approval item /// </summary> /// <param name="project">Project object requesting approval</param> public void InsertModerationQueueProjectApproval(Project project) { if (project == null) throw new ArgumentNullException("project"); var approval = new ProjectApproval { Project = project, ModerationQueue = new ModerationQueue { RequestType = ModerationRequestType.ProjectApproval, StatusType = ModerationStatusType.Open, CreatedDate = DateTime.Now, CreatedBy = _workContext.CurrentUser.Id } }; _moderationQueueProjectApprovalRepository.Insert(approval); }
/// <summary> /// Sends a single message to a user /// </summary> /// <param name="project">The project to send a message about</param> /// <param name="messageType">he message type to send</param> /// <param name="user">User to send the message to</param> /// <param name="authorMessage">Moderator comments to author</param> public void ProjectUserMessage(Project project, MessageType messageType, User user, string authorMessage = "") { string messageUrl = MessageUrl(); var message = new MessageQueue { Priority = 10, User = user }; switch (messageType) { case MessageType.ProjectDisputeRejected: message.Subject = _siteSettings.TwitterHashTag + " - Action Dispute Rejected"; message.ShortBody = "Your action dispute request has been rejected. " + messageUrl; message.Body = WrapStringInHtml("Your action dispute request - " + project.Name + ", has been rejected, you are still not an owner of this project.") + WrapStringInHtml(authorMessage); break; case MessageType.ProjectDisputeApproved: message.Subject = _siteSettings.TwitterHashTag + " - Action Dispute Approved"; message.ShortBody = "Your action dispute request has been approved. " + messageUrl; message.Body = WrapStringInHtml("Your action dispute request - " + project.Name + ", has been approved. We have reinstated you as an owner.") + WrapStringInHtml(authorMessage); break; case MessageType.ProjectDisputeOwnerRemoved: message.Subject = _siteSettings.TwitterHashTag + " - Action Dispute Owner Removed"; message.ShortBody = "You have been removed from - " + project.Name + " due to a dispute." + messageUrl; message.Body = WrapStringInHtml("You have been removed from - " + project.Name + ".") + WrapStringInHtml(authorMessage); break; } if (!string.IsNullOrEmpty(message.Body)) InsertMessageQueue(message); }
/// <summary> /// Messaging service for tweeting about projects /// </summary> /// <param name="project">The project to send out</param> /// <param name="messageType">The type of message to send</param> /// <returns></returns> public bool ProjectTweet(Project project, MessageType messageType) { string projectUrl = ProjectUrl(project.Id); string startDate = project.StartDate != null ? " on " + _webHelper.DateTimeFormat("dd~ MMMM", project.StartDate.Value) : ""; string message; switch (messageType) { case MessageType.TweetProjectApproved: message = string.Format("An event has been created in {0}{1} {2} {3}", project.Locations.First(x => x.Primary).Location.Name, startDate, projectUrl, _siteSettings.TwitterHashTag); if (project.Categories.Count > 0) { string catName = project.Categories.First().Name.ToLower(); string catPrefix = catName == "meeting" ? "Join a" : "Do some"; string catMessage = string.Format("{0} {1} in {2}{3} {4} {5}", catPrefix, catName, project.Locations.First(x => x.Primary).Location.Name, startDate, projectUrl, _siteSettings.TwitterHashTag); message = catMessage.Length > 140 ? message : catMessage; } InsertMessageQueue(new MessageQueue { ShortBody = message, Priority = 10 }); return true; case MessageType.TweetProjectMoreVolunteers: int remainingNumberOfVolunteers = project.NumberOfVolunteers - project.Volunteers.Count; message = string.Format("We need {0} more {1} for this good thing in {2} {3}", remainingNumberOfVolunteers, (remainingNumberOfVolunteers > 1 ? "people" : "person"), project.Locations.First(x => x.Primary).Location.Name, projectUrl); InsertMessageQueue(new MessageQueue { ShortBody = message, Priority = 1 }); return true; } return false; }
private ProjectModel PrepareProjectModel(Project project, int moderationId = 0) { var model = new ProjectModel(); if (project != null) model = project.ToModel(); model.AvailableRecurrenceIntervals = _webHelper.GetAllEnumListItems<RecurrenceInterval>(); model.AvailableDisclosureLevels = _webHelper.GetAllEnumListItems<DisclosureLevel>(); model.AvailableStatus = _webHelper.GetAllEnumListItems<ProjectStatus>(); model.AvailableUsers = _userService.GetAllUsers(true).Select(x => x.ToModel()).ToList(); model.AvailableCategories = _categoryService.GetAllCategories(0, -1, true).Select(x => x.ToModel()).ToList(); model.ModerationId = moderationId; if (model.CreatedById != null) model.CreatedBy = _userService.GetUserById((int) model.CreatedById).ToModel(); var selectCategories = model.AvailableCategories.Where(category => (model.Categories.Any(x => x.Id == category.Id))); selectCategories.ToList().ForEach(x => x.IsChecked = true); return model; }
/// <summary> /// Insert a project /// </summary> /// <param name="project">Project</param> public void InsertProject(Project project) { if (project == null) throw new ArgumentNullException("project"); project.CreatedDate = DateTime.Now; project.LastModifiedDate = DateTime.Now; _projectRepository.Insert(project); }
/// <summary> /// Posts the information on facebook and twitter /// </summary> /// <param name="user">User to send from</param> /// <param name="project">Related project</param> /// <param name="action">Action that occurred</param> public void Post(User user, Project project, ProjectAction action) { // Make sure we have a user and a project if (user == null || project == null) return; // Build the URL of the project var urlHelper = new UrlHelper(_httpContext.Request.RequestContext); string projectUrl = _coreSettings.Domain.TrimEnd('/') + urlHelper.RouteUrl("ProjectDetailTiny", new { project.Id }); // Try and send a Facebook status update if (!string.IsNullOrEmpty(user.FacebookAccessToken)) { try { string description, message; // Build the message depending on the action that occurred switch (action) { case ProjectAction.Approved: description = "I've just setup a good thing on #WeWillGather, can anyone help?"; message = "I've just setup a good thing on #WeWillGather, can anyone help?"; break; default: description = "I've just signed up to a good thing on #WeWillGather!"; message = "I've just signed up to a good thing on #WeWillGather!"; break; } // Build the parameters var parameters = new Dictionary<string, object>(); parameters["description"] = description; parameters["message"] = message; parameters["name"] = project.Name; parameters["link"] = projectUrl; // Post to the user's wall var fb = new FacebookClient(user.FacebookAccessToken); fb.Post(user.FacebookProfile + "/feed", parameters); } catch { } } // Try and send a Twitter status update if (!string.IsNullOrEmpty(user.TwitterAccessToken) && !string.IsNullOrEmpty(user.TwitterAccessSecret)) { try { // Build the oAuth tokens object var tokens = new OAuthTokens { AccessToken = user.TwitterAccessToken, AccessTokenSecret = user.TwitterAccessSecret, ConsumerKey = _siteSettings.TwitterConsumerKey, ConsumerSecret = _siteSettings.TwitterConsumerSecret }; var siteSettings = EngineContext.Current.Resolve<SiteSettings>(); string message; // Build the message depending on the action that occurred switch (action) { case ProjectAction.Approved: message = string.Format("I've just setup a good thing {0} {1}", projectUrl, siteSettings.TwitterHashTag); break; default: message = string.Format("I've just signed up to a good thing {0} {1}", projectUrl, siteSettings.TwitterHashTag); break; } // Update the Twitter status TwitterStatus.Update(tokens, message); } catch { } } }
/// <summary> /// Inserts a message for project management /// </summary> /// <param name="project">The project to send a message about</param> /// <param name="messageType">The message type to send</param> /// <param name="authorMessage">Moderator comments to author</param> /// <param name="volunteerMessage">Moderator comments to volunteers</param> /// <param name="notifyVolunteers">Flag to denote if volunteers need to be notified about the project message</param> /// <param name="overrideSendTo">Override message sender</param> public void ProjectMessage(Project project, MessageType messageType, string authorMessage = "", string volunteerMessage = "", bool notifyVolunteers = true, int overrideSendTo = 0) { if (project == null) throw new ArgumentNullException("project"); string messageUrl = MessageUrl(); string projectUrl = ProjectUrl(project.Id); foreach (var message in project.Owners.Select(owner => new MessageQueue { Priority = 10, User = owner })) { switch (messageType) { case MessageType.ProjectApproved: message.Subject = _siteSettings.TwitterHashTag + " - Action Approval"; message.ShortBody = "Your good thing has been approved " + (!string.IsNullOrEmpty(authorMessage) ? messageUrl : projectUrl); message.Body = WrapStringInHtml("Your good thing. " + project.Name + " has been approved.") + WrapStringInHtml(BuildLink(projectUrl)) + WrapStringInHtml(authorMessage); break; case MessageType.ProjectRejected: message.Subject = _siteSettings.TwitterHashTag + " - Action Rejection"; message.ShortBody = "Your good thing has been denied :-( " + (!string.IsNullOrEmpty(authorMessage) ? messageUrl : projectUrl); message.Body = WrapStringInHtml("Your good thing - " + project.Name + " - has been denied :-(") + WrapStringInHtml(authorMessage); break; case MessageType.ProjectChangeApproved: message.Subject = _siteSettings.TwitterHashTag + " - Action change approval"; message.ShortBody = "You wanted to change your good thing. We said yes " + (!string.IsNullOrEmpty(authorMessage) ? messageUrl : projectUrl); message.Body = WrapStringInHtml("You wanted to change your good thing - " + project.Name + ". We said yes.") + WrapStringInHtml(BuildLink(projectUrl)) + WrapStringInHtml(authorMessage); break; case MessageType.ProjectChangeRejected: message.Subject = _siteSettings.TwitterHashTag + " - Action change rejected"; message.ShortBody = "You wanted to change your good thing, but we can't change it right now - sorry " + (!string.IsNullOrEmpty(authorMessage) ? messageUrl : projectUrl); message.Body = WrapStringInHtml("You wanted to change your good thing - " + project.Name + ", but we can't change it right now - sorry.") + WrapStringInHtml(authorMessage); break; case MessageType.ProjectModerationApproved: message.Subject = _siteSettings.TwitterHashTag + " - Action removed"; message.ShortBody = "Your good thing has been withdrawn because it was reported as a bad thing " + (!string.IsNullOrEmpty(authorMessage) ? messageUrl : projectUrl); message.Body = WrapStringInHtml("Your good thing - " + project.Name + " - has been withdrawn because it was reported as a bad thing.") + WrapStringInHtml(authorMessage); break; case MessageType.ProjectWithdrawalApproved: message.Subject = _siteSettings.TwitterHashTag + " - Your good thing has been withdrawn"; message.ShortBody = "Your good thing has been withdrawn. Thank you, come again soon " + (!string.IsNullOrEmpty(authorMessage) ? messageUrl : projectUrl); message.Body = WrapStringInHtml("Your good thing - " + project.Name + " - has been withdrawn. Thank you, come again soon.") + WrapStringInHtml(authorMessage); break; case MessageType.ProjectWithdrawalRejected: message.Subject = _siteSettings.TwitterHashTag + " - Action Withdrawal Rejected"; message.ShortBody = "Your action withdrawal request has been rejected " + (!string.IsNullOrEmpty(authorMessage) ? messageUrl : projectUrl); message.Body = WrapStringInHtml("Your action withdrawal request - " + project.Name + ", has been rejected. We're keeping your good thing live on the site.") + WrapStringInHtml(authorMessage); break; case MessageType.ProjectDisputeRejected: message.Subject = _siteSettings.TwitterHashTag + " - Action Dispute Rejected"; message.ShortBody = "Your action dispute request has been rejected " + (!string.IsNullOrEmpty(authorMessage) ? messageUrl : projectUrl); message.Body = WrapStringInHtml("Your action dispute request - " + project.Name + ", has been rejected, you are still not an owner of this project.") + WrapStringInHtml(authorMessage); break; case MessageType.ProjectDisputeApproved: message.Subject = _siteSettings.TwitterHashTag + " - Action Dispute Approved"; message.ShortBody = "Your action dispute request has been approved " + (!string.IsNullOrEmpty(authorMessage) ? messageUrl : projectUrl); message.Body = WrapStringInHtml("Your action dispute request - " + project.Name + ", has been approved. We have reinstated you as an owner.") + WrapStringInHtml(authorMessage); break; case MessageType.ProjectDisputeOwnerRemoved: message.Subject = _siteSettings.TwitterHashTag + " - Action Dispute Owner Removed"; message.ShortBody = "You have been removed from \"" + project.Name + "\" due to a dispute " + messageUrl; message.Body = WrapStringInHtml("You have been removed from - " + project.Name + ".") + WrapStringInHtml(authorMessage); break; case MessageType.ProjectRecurrenceScheduled: message.Subject = _siteSettings.TwitterHashTag + " - Project Recurrence Scheduled"; message.ShortBody = "A good thing you organised is a recurring action, can you make the next one? " + projectUrl; message.Body = WrapStringInHtml("A good thing you have helped to organised, \"" + project.Name + "\", is a recurring event. The good thing has now finished, can you make the next occurrence? You can check the new start time at: " + projectUrl); break; } // Do we have a message to send. if (!string.IsNullOrEmpty(message.Body)) InsertMessageQueue(message); } // In some circumstances, we need to send a message to the user who reported the project as well. if (overrideSendTo > 0) { var message2 = new MessageQueue { Priority = 10, User = _userService.GetUserById(overrideSendTo) }; switch (messageType) { case MessageType.ProjectModerationApproved: message2.Subject = _siteSettings.TwitterHashTag + " - Project Removed"; message2.ShortBody = "The action you reported has been removed " + messageUrl; message2.Body = WrapStringInHtml("Reported action - " + project.Name + ". This project has been removed, thank you for reporting the project."); break; case MessageType.ProjectModerationRejected: message2.Subject = _siteSettings.TwitterHashTag + " - Project Moderation"; message2.ShortBody = "We have reviewed the action you reported " + messageUrl; message2.Body = WrapStringInHtml("Reported good thing - " + project.Name + ". We have reviewed the action and we are happy with the content."); break; } if (!string.IsNullOrEmpty(message2.Body)) InsertMessageQueue(message2); } // By default we notify volunteers, we send a message to any volunteer isn't already a product owner. if (notifyVolunteers) { var volunteers = project.Volunteers.Where(volunteer => project.Owners.All(x => x.Id != volunteer.Id)).ToList(); if (volunteers.Count > 0) { foreach (var message in volunteers.Select(user => new MessageQueue { Priority = 20, User = user })) { switch (messageType) { case MessageType.ProjectChangeApproved: message.Subject = _siteSettings.TwitterHashTag + " - " + project.Name + " : Action Update"; message.ShortBody = "Changes have been made to a good thing you signed up for " + messageUrl; message.Body = WrapStringInHtml(project.Name + ". Changes have been made to a good thing you signed up for.") + WrapStringInHtml(BuildLink(projectUrl)) + WrapStringInHtml(volunteerMessage); break; case MessageType.ProjectModerationApproved: message.Subject = _siteSettings.TwitterHashTag + " - " + project.Name + " : Action Withdrawn"; message.ShortBody = "A good thing you signed up for has sadly had to be withdrawn by its creator " + messageUrl; message.Body = WrapStringInHtml(project.Name + ". A good thing you signed up for has sadly had to be withdrawn by its creator.") + WrapStringInHtml(volunteerMessage); break; case MessageType.ProjectWithdrawalApproved: message.Subject = _siteSettings.TwitterHashTag + " - " + project.Name + " : Action Withdrawn"; message.ShortBody = "A good thing you signed up for has been cancelled " + messageUrl; message.Body = WrapStringInHtml(project.Name + ". A good thing you signed up for has been cancelled.") + WrapStringInHtml(volunteerMessage); break; case MessageType.ProjectRecurrenceScheduled: message.Subject = _siteSettings.TwitterHashTag + " - Project Recurrence Scheduled"; message.ShortBody = "A good thing you volunteered for is a recurring event, can you make the next one? " + projectUrl; message.Body = WrapStringInHtml("A good thing you have signed up for, \"" + project.Name + "\", is a recurring action. The good thing has now finished, can you make the next occurrence? You can check the new start time at: " + projectUrl); break; } if (!string.IsNullOrEmpty(message.Body)) InsertMessageQueue(message); } } } }