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 UserProfile(vmAccountUserProfile model) { //security validation (only allow site admin or user to edit their own profile) if ((!User.IsInRole("Admins")) && (model.UserIDX != db_Accounts.GetUserIDX())) { return(RedirectToAction("AccessDenied", "Home")); } if (ModelState.IsValid) { if (model.UserIDX > 0) { var strippedPhone = Regex.Replace(model.Phone ?? "", "[^0-9]", ""); if ((model.LinkedIn ?? "").Contains("www")) { try { Uri uri = new Uri(model.LinkedIn); model.LinkedIn = uri.Segments.Last(); } catch { } } int SuccID = db_Accounts.UpdateT_OE_USERS(model.UserIDX, null, null, model.FName, model.LName, model.Email, model.ActInd, null, null, null, strippedPhone, model.PhoneExt, null, null, model.OrgIDX, model.JobTitle, model.LinkedIn, model.NodeAdmin, model.ExcludeBadges); //update user expertise db_EECIP.DeleteT_OE_USER_EXPERTISE(model.UserIDX); foreach (string expertise in model.SelectedExpertise ?? new List <string>()) { db_EECIP.InsertT_OE_USER_EXPERTISE(model.UserIDX, expertise); } //award profile badge if (db_Accounts.GetUserIDX() == model.UserIDX) { db_Forum.EarnBadgeController(model.UserIDX, "UserProfile"); } ////avatar handling if (model.imageBrowes != null) { // ******************** VALIDATION START ******************************** //File too big check if (model.imageBrowes.ContentLength > 10485760) { TempData["Error"] = "File cannot exceed 10MB"; return(RedirectToAction("UserProfile", new { a = model.uListInd })); } //invalid file extension check var fileExtension = Path.GetExtension(model.imageBrowes.FileName); List <string> allowedExtensions = new List <string> { ".jpg", ".jpeg", ".png", ".bmp" }; if (!allowedExtensions.Contains(fileExtension)) { TempData["Error"] = "Invalid file type"; return(RedirectToAction("UserProfile", new { a = model.uListInd })); } // ******************** VALIDATION END ******************************** // Convert to Png var outputStream = model.imageBrowes.InputStream.ConvertImage(ImageFormat.Png); //save to db db_Accounts.UpdateT_OE_USERS_Avatar(model.UserIDX, Utils.ConvertGenericStreamToByteArray(outputStream)); //save to file system string fileName1 = model.UserIDX.ToString() + ".png"; model.imageBrowes.SaveAs(Server.MapPath("/Content/Images/Users/" + fileName1)); //award badge if (db_Accounts.GetUserIDX() == model.UserIDX) { db_Forum.EarnBadgeController(model.UserIDX, "Photogenic"); } } //update azure search AzureSearch.PopulateSearchIndexUsers(model.UserIDX); if (SuccID > 0) { TempData["Success"] = "Update successful."; } else { TempData["Error"] = "Error updating data."; } } } return(RedirectToAction("UserProfile", new { a = model.uListInd })); }