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; }
public ActionResult Edit(ProjectModel model, FormCollection form) { if (!_permissionService.Authorize(PermissionProvider.ManageProjects)) return AccessDeniedView(); if (model.ModerationId > 0) { // Make sure that the moderation id is valid var queue = _moderationQueueService.GetProjectApprovalByModerationQueueId(model.ModerationId); if (queue == null || queue.Deleted) return RedirectToAction("index", "moderation"); PrepareModerationBreadcrumbs(); AddBreadcrumb("Action Approval Request", null); } else { PrepareBreadcrumbs(); AddBreadcrumb("Edit Action", null); } // Get the action var project = _projectService.GetProjectById(model.Id); if (project == null) return RedirectToAction("index"); // Populate model with post back information var selectedCategoryIds = form["SelectedCategories"] != null ? form["SelectedCategories"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() : new List<string>(); var availableCategories = _categoryService.GetAllCategories(); project.Categories.Clear(); foreach (var categoryId in selectedCategoryIds.Select(int.Parse)) project.Categories.Add(availableCategories.First(x => x.Id == categoryId)); project.LastModifiedBy = _workContext.CurrentUser.Id; // Update fields project.ChildFriendly = model.ChildFriendly; project.EmailAddress = model.EmailAddress; project.EmailDisclosureId = model.EmailDisclosureId; project.EndDate = model.EndDate; project.Equipment = model.Equipment; project.GettingThere = model.GettingThere; project.Name = model.Name; project.NumberOfVolunteers = model.NumberOfVolunteers; project.Objective = model.Objective; project.RecurrenceIntervalId = model.RecurrenceIntervalId; project.Recurrence = model.Recurrence; project.Skills = model.Skills; project.StartDate = model.StartDate; project.Telephone = model.Telephone; project.TelephoneDisclosureId = model.TelephoneDisclosureId; project.VolunteerBenefits = model.VolunteerBenefits; project.Website = model.Website; project.WebsiteDisclosureId = model.WebsiteDisclosureId; project.IsRecurring = model.IsRecurring; project.ModeratorNotes = model.ModerationNotes; if (ModelState.IsValid) { try { // Update the project status if (model.ModerationId > 0) { project.StatusId = (int)ProjectStatus.Open; } else { // Make sure we have the correct status for the date provided // This is important if a project date is changed after it's already started if (project.Status == ProjectStatus.InProgress) { if (project.StartDate > DateTime.Now) { project.StatusId = (int) ProjectStatus.Open; } else if (project.EndDate < DateTime.Now) { project.StatusId = (int) ProjectStatus.Closed; } } else if (project.Status == ProjectStatus.Closed && project.StartDate > DateTime.Now) { project.StatusId = (int) ProjectStatus.Open; } else if (project.Status == ProjectStatus.Closed && project.StartDate < DateTime.Now && project.EndDate > DateTime.Now) { project.StatusId = (int) ProjectStatus.InProgress; } else if (project.Status == ProjectStatus.Open && project.StartDate < DateTime.Now) { if (project.EndDate > DateTime.Now) { project.StatusId = (int) ProjectStatus.InProgress; } else { project.StatusId = (int) ProjectStatus.Closed; } } } // Commit the changes _projectService.UpdateProject(project); // Work out what to do next if (model.ModerationId == 0) { SuccessNotification("The action details have been updated successfully."); return RedirectToAction("edit", project.Id); } // Queue a message to the project owner to say their project has been approved _messageQueueService.ProjectMessage(project, MessageType.ProjectApproved, model.ModerationComment); // Queue a tweet from the site owner account to say a new project has been created _messageQueueService.ProjectTweet(project, MessageType.TweetProjectApproved); // Post to the user's Twitter and Facebook profile to promote the action _userService.Post(project.Owners.FirstOrDefault(), project, ProjectAction.Approved); // Mark the moderation request as resolved var queueUpdate = _moderationQueueService.GetById(model.ModerationId); queueUpdate.Notes = model.ModerationComment; queueUpdate.StatusType = ModerationStatusType.Closed; _moderationQueueService.UpdateModerationQueue(queueUpdate); SuccessNotification("The moderation request has been resolved, the action has been approved."); return RedirectToAction("index", "moderation"); } catch (Exception ex) { ErrorNotification(ex.ToString()); ErrorNotification("An error occurred saving the action details, please try again."); } } else { ErrorNotification("We were unable to make the change, please review the form and correct the errors."); } return View(PrepareProjectModel(project, model.ModerationId)); }
public ActionResult Hide(ProjectModel model) { if (!_permissionService.Authorize(PermissionProvider.ManageProjects)) return AccessDeniedView(); if (model.ModerationId > 0) { // Check the moderation id is valid var queue = _moderationQueueService.GetProjectApprovalByModerationQueueId(model.ModerationId); if (queue == null || queue.Deleted) return RedirectToAction("index", "moderation"); PrepareModerationBreadcrumbs(); AddBreadcrumb("Action Approval Request", null); } else { PrepareBreadcrumbs(); AddBreadcrumb("Edit Action", null); } // Get the project var project = _projectService.GetProjectById(model.Id); if (project == null) return RedirectToAction("index"); project.ModeratorNotes = model.ModerationNotes; // Make sure a comment has been entered explaining why the project was not approved if (model.ModerationId > 0 && string.IsNullOrEmpty(model.ModerationComment)) ModelState.AddModelError("ModerationComment", "Please fill in a moderation comment before rejecting the project."); // Make sure the model is valid if (ModelState.IsValid) { try { // Process a standard show/hide if (model.ModerationId == 0) { // Change the status // If the project is already open or in progress, close it // If the project is closed and the start date is in the future, open it // If the project is closed and the start date has passed but the end date is in the future, mark it as in progress if (project.Status == ProjectStatus.Open || project.Status == ProjectStatus.InProgress) project.StatusId = (int) ProjectStatus.Closed; else if (project.StartDate > DateTime.Now) project.StatusId = (int) ProjectStatus.Open; else if(project.EndDate > DateTime.Now) project.StatusId = (int) ProjectStatus.InProgress; // Commit the changes _projectService.UpdateProject(project); SuccessNotification(project.Status == ProjectStatus.Open ? "The action has been opened successfully." : "The action has been closed successfully."); return RedirectToAction("edit", project.Id); } // If we've reached this point, we must be moderating a new project // Flag the project status as rejected project.StatusId = (int)ProjectStatus.Rejected; // Commit the changes _projectService.UpdateProject(project); SuccessNotification("The action has been rejected."); // Queue messages _messageQueueService.ProjectMessage(project, MessageType.ProjectRejected, model.ModerationComment); // Mark the moderation request as resolved var queueUpdate = _moderationQueueService.GetById(model.ModerationId); queueUpdate.Notes = model.ModerationComment; queueUpdate.StatusType = ModerationStatusType.Closed; _moderationQueueService.UpdateModerationQueue(queueUpdate); return RedirectToRoute("Admin_default", new { Controller = "moderation", Action = "index" }); } catch { ErrorNotification("An error occurred hiding the action, please try again."); } } return View(PrepareProjectModel(project, model.ModerationId)); }
public ActionResult OrganiserContact(ProjectModel project, UserModel organiser, bool isOwner = false) { bool isVolunteer = _workContext.CurrentUser != null && project.Volunteers.Any(x => x.Id == _workContext.CurrentUser.Id); var model = new Dictionary<string, string>(); if (organiser.FacebookProfile != null) model.Add("Facebook", string.Format("http://www.facebook.com/profile.php?id={0}", organiser.FacebookProfile)); if (organiser.TwitterProfile != null) model.Add("Twitter", string.Format("http://twitter.com/account/redirect_by_id?id={0}", organiser.TwitterProfile)); if (isOwner) { if (!string.IsNullOrEmpty(project.EmailAddress) && project.EmailDisclosureLevel == DisclosureLevel.Public || (project.EmailDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Email", string.Format("mailto:{0}", project.EmailAddress.EncodeEmail())); if (!string.IsNullOrEmpty(project.Telephone) && project.TelephoneDisclosureLevel == DisclosureLevel.Public || (project.TelephoneDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Call", string.Format("tel:{0}", project.Telephone)); if (!string.IsNullOrEmpty(project.Website) && project.WebsiteDisclosureLevel == DisclosureLevel.Public || (project.WebsiteDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Website", project.Website); } else { if (!string.IsNullOrEmpty(project.EmailAddress) && organiser.EmailDisclosureLevel == DisclosureLevel.Public || (organiser.EmailDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Email", string.Format("mailto:{0}", organiser.Email.EncodeEmail())); if (!string.IsNullOrEmpty(project.Telephone) && organiser.TelephoneDisclosureLevel == DisclosureLevel.Public || (organiser.TelephoneDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Call", string.Format("tel:{0}", organiser.Telephone)); if (!string.IsNullOrEmpty(project.Website) && organiser.WebsiteDisclosureLevel == DisclosureLevel.Public || (organiser.WebsiteDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Website", organiser.Website); } return PartialView("_OrganiserContact", model); }
public ActionResult Edit(ProjectModel model, FormCollection form, int id, string seoName, string locationSeoName, bool projectUpdate) { var project = _projectService.GetProjectById(id); if (project == null || (project.Status != ProjectStatus.Open && project.Status != ProjectStatus.InProgress)) return RedirectToRoute("ProjectDetail", new { locationSeoName, seoName, id }); var modelProject = project.ToModel(); bool projectHasBeenChanged = false; // Make sure the user is logged in and is an organiser of the project if(_workContext == null || project.Owners.All(x => x.Id != _workContext.CurrentUser.Id)) return RedirectToRoute("ProjectDetail", new { locationSeoName, seoName, id }); // Get the list of selected categories var selectedCategoryIds = form["SelectedCategories"] != null ? form["SelectedCategories"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() : new List<string>(); // Check what type of button was clicked if (projectUpdate) { if (ModelState.IsValid) { var newProject = model.ToEntity(); if (newProject.Name.Length > PROJECT_MAX_LENGTH) newProject.Name = newProject.Name.Substring(0, PROJECT_MAX_LENGTH); newProject.StartDate = new DateTime(model.StartDate.Value.Year, model.StartDate.Value.Month, model.StartDate.Value.Day, model.StartHour, model.StartMinutes, 0); newProject.EndDate = new DateTime(model.EndDate.Value.Year, model.EndDate.Value.Month, model.EndDate.Value.Day, model.EndHour, model.EndMinutes, 0); var availableCategories = _categoryService.GetAllCategories(); foreach (var categoryId in selectedCategoryIds.Select(int.Parse)) newProject.Categories.Add(availableCategories.First(x => x.Id == categoryId)); if (newProject.Name != project.Name) projectHasBeenChanged = true; if (newProject.Objective != project.Objective) projectHasBeenChanged = true; if (newProject.Latitude != project.Latitude) projectHasBeenChanged = true; if (newProject.Longitude != project.Longitude) projectHasBeenChanged = true; if (newProject.GettingThere != project.GettingThere) projectHasBeenChanged = true; if (newProject.NumberOfVolunteers != project.NumberOfVolunteers) projectHasBeenChanged = true; if (newProject.StartDate != project.StartDate) projectHasBeenChanged = true; if (newProject.EndDate != project.EndDate) projectHasBeenChanged = true; if (newProject.ChildFriendly != project.ChildFriendly) projectHasBeenChanged = true; if (newProject.Skills != project.Skills) projectHasBeenChanged = true; if (newProject.Equipment != project.Equipment) projectHasBeenChanged = true; if (newProject.VolunteerBenefits != project.VolunteerBenefits) projectHasBeenChanged = true; if (newProject.EmailAddress != project.EmailAddress) projectHasBeenChanged = true; if (newProject.EmailDisclosureId != project.EmailDisclosureId) projectHasBeenChanged = true; if (newProject.Telephone != project.Telephone) projectHasBeenChanged = true; if (newProject.TelephoneDisclosureId != project.TelephoneDisclosureId) projectHasBeenChanged = true; if (newProject.Website != project.Website) projectHasBeenChanged = true; if (newProject.WebsiteDisclosureId != project.WebsiteDisclosureId) projectHasBeenChanged = true; if (newProject.Categories.Count(j => project.Categories.Any(c => c.Id == j.Id)) != newProject.Categories.Count) projectHasBeenChanged = true; // Compare the project if (!projectHasBeenChanged) { AddNotification(NotifyType.Error, "You didn't change the project.", true); } else { newProject.CreatedBy = _workContext.CurrentUser.Id; newProject.LastModifiedBy = _workContext.CurrentUser.Id; newProject.Owners.Add(_workContext.CurrentUser); newProject.Status = ProjectStatus.PendingChangeApproval; // Insert the temporary project _projectService.InsertProject(newProject); // Get the location entity based on the final resting place of the map marker var location = _geolocationService.GetLocationFromLatLng(newProject.Latitude, newProject.Longitude); if (location != null) { newProject.Locations.Add(new ProjectLocation { LocationId = location.Id, Primary = true, ProjectId = newProject.Id }); var parent = location.ParentLocation; while (parent != null) { newProject.Locations.Add(new ProjectLocation { LocationId = parent.Id, Primary = false, ProjectId = newProject.Id }); parent = parent.ParentLocation; } } // Join the locations to the newly created project entity _projectService.UpdateProject(newProject); // Raise the moderation request _moderationQueueService.InsertModerationQueueProjectChange(project, newProject); // Do the update AddNotification(NotifyType.Success, "Thanks, we see you wish to change the project. A #wewillgather moderator will mull over your request. You'll get an email or direct message on the Twitter with a response.", true); var primaryLocation = project.Locations.First(l => l.Primary).Location; return RedirectToRoute("ProjectDetail", new { id, seoName = project.GetSeoName(), locationSeoName = primaryLocation.SeoName }); } } } else { if (form["update"].ToLower() == "add as co-organisers") { // Promote volunteers var selectedVolunteerIds = form["SelectedVolunteers"] != null ? form["SelectedVolunteers"].Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList() : new List<string>(); foreach (var selectedVolunteerId in selectedVolunteerIds) { _projectService.InsertProjectUserHistory(new ProjectUserHistory { AffectedUser = _userService.GetUserById(int.Parse(selectedVolunteerId)), CommittingUser = _workContext.CurrentUser, ProjectUserAction = ProjectUserAction.Added, Project = project, ProjectUserActionId = (int)ProjectUserAction.Added }); project.Owners.Add(_userService.GetUserById(int.Parse(selectedVolunteerId))); } } else { // Remove organisers var selectedOwnersIds = form["SelectedOwners"] != null ? form["SelectedOwners"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() : new List<string>(); foreach (var selectedOwnerId in selectedOwnersIds) { if (int.Parse(selectedOwnerId) != modelProject.CreatedById) { _projectService.InsertProjectUserHistory(new ProjectUserHistory { AffectedUser = _userService.GetUserById(int.Parse(selectedOwnerId)), CommittingUser = _workContext.CurrentUser, ProjectUserAction = ProjectUserAction.Added, Project = project, ProjectUserActionId = (int)ProjectUserAction.Removed }); project.Owners.Remove(_userService.GetUserById(int.Parse(selectedOwnerId))); } } } _projectService.UpdateProject(project); modelProject = project.ToModel(); } model.AvailableCategories = _categoryService.GetAllCategories().Select(x => x.ToModel()).ToList(); model.AvailableDisclosureLevels = _webHelper.GetAllEnumListItems<DisclosureLevel>(); model.AvailableHours = _webHelper.GetAvailableHours(); model.AvailableMinutes = _webHelper.GetAvailableMinutes(); model.AvailableRecurrenceIntervals = _webHelper.GetAllEnumListItems<RecurrenceInterval>(); model.CreatedById = modelProject.CreatedById; model.CurrentUserId = _workContext.CurrentUser.Id; model.Locations = modelProject.Locations; model.Owners = modelProject.Owners; model.SeoName = modelProject.SeoName; model.Volunteers = modelProject.Volunteers; foreach (var categoryId in selectedCategoryIds.Select(int.Parse)) model.AvailableCategories.First(x => x.Id == categoryId).IsChecked = true; return View(model); }
public ActionResult Add(ProjectModel model, FormCollection form, int id) { var selectedCategoryIds = form["SelectedCategories"] != null ? form["SelectedCategories"].Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList() : new List<string>(); // Make sure we have recurrence details if recurrence is enabled if (model.IsRecurring) { if (model.RecurrenceIntervalId == 0) ModelState.AddModelError("RecurrenceIntervalId", "Please select the recurrence interval."); if (model.Recurrence == 0) ModelState.AddModelError("Recurrence", "Please select the number of times the event will recur."); } // Make sure we have a location if (model.Latitude == 0 || model.Latitude == 999 || model.Longitude == 0 || model.Longitude == 999) { if (!string.IsNullOrEmpty(model.LocationInput)) { decimal latitude; decimal longitude; _geolocationService.GetLatLng(model.LocationInput, out latitude, out longitude); if (latitude != 999 && longitude != 999) { model.Latitude = latitude; model.Longitude = longitude; } else { // No location could be found ModelState.AddModelError("LocationInput", "We couldn't find a location for '" + model.LocationInput + "'. Make sure the location is spelled correctly or try entering a postcode."); } } else { // No location has been provided ModelState.AddModelError("LocationInput", "Please enter the location or postcode of where the good thing will take place."); } } if (ModelState.IsValid) { Project project; // Build the project entity if (id == 0) { project = model.ToEntity(); } else { if (_workContext == null) return RedirectToRoute("AddProject"); project = _projectService.GetProjectById(id); if (project == null || project.TwitterProfile != _workContext.CurrentUser.TwitterProfile || project.CreatedBy != null) return RedirectToRoute("AddProject"); model.ToEntity(project); } // Make sure the project length doesn't exceed the max length // This is only to cover us incase someone tries to alter the front end validation if (project.Name.Length > PROJECT_MAX_LENGTH) project.Name = project.Name.Substring(0, PROJECT_MAX_LENGTH); try { project.StartDate = new DateTime(model.StartDate.Value.Year, model.StartDate.Value.Month, model.StartDate.Value.Day, model.StartHour, model.StartMinutes, 0); project.EndDate = new DateTime(model.EndDate.Value.Year, model.EndDate.Value.Month, model.EndDate.Value.Day, model.EndHour, model.EndMinutes, 0); var availableCategories = _categoryService.GetAllCategories(); foreach (var categoryId in selectedCategoryIds.Select(int.Parse)) project.Categories.Add(availableCategories.First(x => x.Id == categoryId)); project.CreatedBy = _workContext.CurrentUser.Id; project.LastModifiedBy = _workContext.CurrentUser.Id; project.Owners.Add(_workContext.CurrentUser); project.Status = ProjectStatus.PendingApproval; // Get the location entity based on the final resting place of the map marker var location = _geolocationService.GetLocationFromLatLng(project.Latitude, project.Longitude); // If we have a location, store it against the project record var projectLocations = new List<ProjectLocation>(); if (location != null) { projectLocations.Add(new ProjectLocation { LocationId = location.Id, Primary = true }); var parent = location.ParentLocation; while (parent != null) { projectLocations.Add(new ProjectLocation { LocationId = parent.Id, Primary = false }); parent = parent.ParentLocation; } } if (id > 0) { // Loop through each existing project location, // deleting them from the database. int locationCount = project.Locations.Count; for (var i = 0; i < locationCount; i++) { var item = project.Locations.ElementAt(0); _projectService.DeleteProjectLocation(item); project.Locations.Remove(item); } // Loop each new project location, setting the project Id // and adding to the project location list foreach (var item in projectLocations) { item.ProjectId = id; project.Locations.Add(item); } // Update the existing entity _projectService.UpdateProject(project); } else { // Insert the new entity _projectService.InsertProject(project); // Set the project location project id projectLocations.ForEach(x => x.ProjectId = project.Id); project.Locations = projectLocations; // Update the project locations _projectService.UpdateProject(project); } _moderationQueueService.InsertModerationQueueProjectApproval(project); if (project.Id > 0) { TempData.Add("newProjectId", project.Id); return RedirectToRoute("ConfirmProject"); } _logService.Error("An unexpected error occurred while saving the project."); ErrorNotification("An error occurred creating your project, please try again."); } catch (Exception ex) { _logService.Error(ex.Message, ex, _workContext.CurrentUser); ErrorNotification("An error occurred creating your project, please try again."); } } model.AvailableDisclosureLevels = _webHelper.GetAllEnumListItems<DisclosureLevel>(); model.AvailableHours = _webHelper.GetAvailableHours(); model.AvailableMinutes = _webHelper.GetAvailableMinutes(); model.AvailableRecurrenceIntervals = _webHelper.GetAllEnumListItems<RecurrenceInterval>(); model.AvailableCategories = _categoryService.GetAllCategories().Select(x => x.ToModel()).ToList(); foreach (var categoryId in selectedCategoryIds.Select(int.Parse)) model.AvailableCategories.First(x => x.Id == categoryId).IsChecked = true; model.Locations = new List<ProjectLocationModel>(); return View(model); }
public ActionResult Add(int id) { var projectModel = new ProjectModel(); if (id > 0) { var model = _projectService.GetProjectById(id); if (model == null || model.TwitterProfile != _workContext.CurrentUser.TwitterProfile || model.CreatedBy != null) { ErrorNotification("Looks like you tried to click another Good Person's Tweet! Why not setup your own Good Thing below?"); return RedirectToRoute("AddProject"); } projectModel = model.ToModel(); projectModel.ReloadFromLocalStorage = false; } else { projectModel.ReloadFromLocalStorage = true; } AddHomeBreadcrumb(); AddBreadcrumb("Add Project", Url.RouteUrl("AddProject", new { projectModel.Id })); projectModel.AvailableCategories = _categoryService.GetAllCategories().Select(x => x.ToModel()).ToList(); projectModel.AvailableDisclosureLevels = _webHelper.GetAllEnumListItems<DisclosureLevel>(); projectModel.AvailableHours = _webHelper.GetAvailableHours(); projectModel.AvailableMinutes = _webHelper.GetAvailableMinutes(); projectModel.AvailableRecurrenceIntervals = _webHelper.GetAllEnumListItems<RecurrenceInterval>(); projectModel.ChildFriendly = false; projectModel.EmailAddress = _workContext.CurrentUser.Email; projectModel.EmailDisclosureId = _workContext.CurrentUser.EmailDisclosureId; projectModel.StartHour = 9; projectModel.Telephone = _workContext.CurrentUser.Telephone; projectModel.TelephoneDisclosureId = _workContext.CurrentUser.TelephoneDisclosureId; projectModel.Website = _workContext.CurrentUser.Website; projectModel.WebsiteDisclosureId = _workContext.CurrentUser.WebsiteDisclosureId; return View(projectModel); }
public static ProjectModel ToModel(this Project entity) { if (entity == null) return null; var model = new ProjectModel { Categories = entity.Categories.Select(ToModel).ToList(), ChildFriendly = entity.ChildFriendly, CreatedById = entity.CreatedBy, CreatedDate = entity.CreatedDate, EmailAddress = entity.EmailAddress, EmailDisclosureId = entity.EmailDisclosureId, EmailDisclosureLevel = entity.EmailDisclosureLevel, EndDate = entity.EndDate, Equipment = entity.Equipment, GettingThere = entity.GettingThere, Id = entity.Id, IsRecurring = entity.IsRecurring, LastModeratorApprovalBy = entity.LastModeratorApprovalBy, LastModeratorApprovalDate = entity.LastModeratorApprovalDate, LastModifiedBy = entity.LastModifiedBy, LastModifiedDate = entity.LastModifiedDate, Latitude = entity.Latitude, Locations = entity.Locations.Select(ToModel).ToList(), Longitude = entity.Longitude, Name = entity.Name, NumberOfVolunteers = entity.NumberOfVolunteers, Objective = entity.Objective, Owners = entity.Owners.Select(ToModel).ToList(), Recurrence = entity.Recurrence, RecurrenceIntervalId = entity.RecurrenceIntervalId, RemainingNumberOfVolunteers = entity.NumberOfVolunteers - entity.Volunteers.Count, SeoName = entity.GetSeoName(), Skills = entity.Skills, StartDate = entity.StartDate, Status = entity.Status, StatusId = entity.StatusId, Telephone = entity.Telephone, TelephoneDisclosureId = entity.TelephoneDisclosureId, TelephoneDisclosureLevel = entity.TelephoneDisclosureLevel, Volunteers = entity.Volunteers.Select(ToModel).ToList(), VolunteerBenefits = entity.VolunteerBenefits, Website = entity.Website, WebsiteDisclosureId = entity.WebsiteDisclosureId, WebsiteDisclosureLevel = entity.WebsiteDisclosureLevel, ModerationNotes = entity.ModeratorNotes }; return model; }