public ActionResult EditPost(vmForumTopicCreate model) { //get topic being edited Topic _topic = db_Forum.GetTopic_ByID(model.TopicId); if (_topic != null) { // Update the Topic db_Forum.InsertUpdateTopic(model, 0); Guid?newPostID = db_Forum.InsertUpdatePost(model.Id, model.Content, null, null, null, null, null, null, null, null, null, true); // 7. Tag handling db_Forum.DeleteTopicTags(model.TopicId, "Topic Tag"); foreach (string feature in model.SelectedTags ?? new List <string>()) { db_Forum.InsertUpdateTopicTags(model.TopicId, "Topic Tag", feature); } // 11. Update Azure search AzureSearch.PopulateSearchIndexForumTopic(model.TopicId); } return(RedirectToAction("ShowTopic", "Forum", new { slug = _topic.Slug })); }
public ActionResult SearchAdminPopulateIndex() { try { //***********PROJECTS ************************** //first reset all projects to unsynced db_EECIP.ResetT_OE_PROJECTS_Unsynced(); //then send all unsynced projects to Azure AzureSearch.PopulateSearchIndexProject(null); //***********AGENCIES ************************** //reset all agencies to unsynced db_Ref.ResetT_OE_ORGANIZATION_Unsynced(); //then send all unsynced agencies to Azure AzureSearch.PopulateSearchIndexOrganization(null); //***********ENT SERVICES ************************** db_EECIP.ResetT_OE_ORGANIZATION_ENT_SVCS_Unsynced(); //then send all unsynced agencies to Azure AzureSearch.PopulateSearchIndexEntServices(null); //***********PEOPLE ************************** db_Accounts.ResetT_OE_USERS_Unsynced(); //then send all unsynced agencies to Azure AzureSearch.PopulateSearchIndexUsers(null); //***********FORUM TOPICS ************************** db_Forum.UpdateTopic_SetAllUnsynced(); //then send all unsynced agencies to Azure AzureSearch.PopulateSearchIndexForumTopic(null); TempData["Success"] = "Search index populated."; } catch (Exception ex) { TempData["Error"] = ex.ToString().SubStringPlus(0, 100); } return(RedirectToAction("SearchAdmin", "Admin")); }
public ActionResult Create(vmForumTopicCreate topicViewModel) { int UserIDX = db_Accounts.GetUserIDX(); // If viewModel is returned back to the view, repopulate view model fist topicViewModel.OptionalPermissions = GetOptionalPermissions(); topicViewModel.Categories = ddlForumHelpers.get_ddl_categories(); topicViewModel.IsTopicStarter = true; //topicViewModel.PollAnswers = topicViewModel.PollAnswers ?? new List<string>(); topicViewModel.SelectedTags = topicViewModel.SelectedTags ?? new List <string>(); topicViewModel.AllTags = db_Forum.GetTopicTags_ByAttributeAll(Guid.NewGuid(), "Project Feature").Select(x => new SelectListItem { Value = x, Text = x }); /*---- End Re-populate ViewModel ----*/ if (ModelState.IsValid) { // ************************ VALIDATION ********************************************** // See if the user has actually added some content to the topic if (string.IsNullOrEmpty(topicViewModel.Content)) { TempData["Error"] = "You must supply content for the post."; RedirectToAction("Create"); } // Check posting flood control if (!db_Forum.PassedTopicFloodTest(topicViewModel.Name, UserIDX)) { TempData["Error"] = "Can only post once per minute"; RedirectToAction("Create"); } // Log user out if they are LockedOut but still authenticated T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(UserIDX); if (u != null && u.LOCKOUT_ENABLED) { FormsAuthentication.SignOut(); return(RedirectToAction("Index", "Home")); } // Check Permissions for topic opions if (!topicViewModel.OptionalPermissions.CanLockTopic) { topicViewModel.IsLocked = false; } // ************************ END VALIDATION ********************************************** // 1. Create the Topic Topic _Topic = db_Forum.InsertUpdateTopic(topicViewModel, UserIDX); if (_Topic != null) { // 2. Create Post and add to Topic Guid?_postID = db_Forum.InsertUpdatePost(null, topicViewModel.Content, null, null, true, null, null, null, null, _Topic.Id, UserIDX, false); if (_postID != null) { // 3. Reupdate the topic with post ID db_Forum.InsertUpdateTopic_withPost(_Topic.Id, _postID.ConvertOrDefault <Guid>()); // 4. Update the users points score for posting db_Forum.InsertUpdateMembershipUserPoints(null, 1, System.DateTime.UtcNow, 0, _postID, null, UserIDX); // 5. Poll handling //if (topicViewModel.PollAnswers.Count(x => x != null) > 1) //{ // Create a new Poll // var newPoll = new Poll // { // User = loggedOnUser, // ClosePollAfterDays = topicViewModel.PollCloseAfterDays // }; // // Create the poll // _pollService.Add(newPoll); // // Now sort the answers // var newPollAnswers = new List<PollAnswer>(); // foreach (var pollAnswer in topicViewModel.PollAnswers) // { // if (pollAnswer.Answer != null) // { // // Attach newly created poll to each answer // pollAnswer.Poll = newPoll; // _pollAnswerService.Add(pollAnswer); // newPollAnswers.Add(pollAnswer); // } // } // // Attach answers to poll // newPoll.PollAnswers = newPollAnswers; // // Add the poll to the topic // topic.Poll = newPoll; //} // 6. File handling if (topicViewModel.Files != null && topicViewModel.Files.Any()) { UPloadPostFiles(topicViewModel.Files, UserIDX, _postID.ConvertOrDefault <Guid>()); } // 7. Tag handling db_Forum.DeleteTopicTags(_Topic.Id, "Topic Tag"); foreach (string feature in topicViewModel.SelectedTags ?? new List <string>()) { db_Forum.InsertUpdateTopicTags(_Topic.Id, "Topic Tag", feature); } // 8. Subscribe the user to the topic if they have checked the checkbox if (topicViewModel.SubscribeToTopic) { db_Forum.InsertUpdateTopicNotification(null, _Topic.Id, UserIDX); } // 9. Success so now send the emails //NotifyNewTopics(category, topic, unitOfWork); // 10. Badge Checking db_Forum.EarnBadgePostTopicEvent(UserIDX); // 11. Update Azure search AzureSearch.PopulateSearchIndexForumTopic(_Topic.Id); // Redirect to the newly created topic return(RedirectToAction("ShowTopic", "Forum", new { slug = _Topic.Slug })); } } } if (TempData["Error"] == null) { TempData["Error"] = "Unable to save data"; } return(View(topicViewModel)); }