protected void btnCreateEvent_Click(object sender, EventArgs e) { HelperMethods.ActivityTracker.Track("Created a new Calendar Event", (int)UserActionEnum.Created); try { // Declare instance of calendar CalendarEvent calEvent = new CalendarEvent(); calEvent.CalendarEventName = txtEventName.Text; calEvent.CalendarEventDescription = txtEventDescription.Text; calEvent.CalendarEventDate = Convert.ToDateTime(txtEventDate.Text + " " + txtEventTime.Text); calEvent.RoleName = ddlVisibilty.SelectedValue; // Assign null if no file is selected int?noFileSelected = null; calEvent.FileId = (ddlEventFile.SelectedValue == "null") ? noFileSelected : Convert.ToInt32(ddlEventFile.SelectedValue); // Add record and save to db db.CalendarEvents.Add(calEvent); db.SaveChanges(); // Create Notification string[] roleNamesArray = { calEvent.RoleName }; NotificationCreator.CreateNotification(roleNamesArray, "Event Created", calEvent.CalendarEventName, DateTime.Now, "Info", null, null); // Reset the controls ResetModalControls(); ResetButtons(true); PopulateCalendarData(); } catch (DataException dx) { LogFile.WriteToFile("EventManager.aspx.cs", "btnCreateEvent_Click", dx, "An Event failed to be created", "HPSErrorLog.txt"); } }
protected void btnDeleteEvent_Click(object sender, EventArgs e) { HelperMethods.ActivityTracker.Track("Deleted a Calendar Event", (int)UserActionEnum.Deleted); try { // Get the record id from the button int id = Convert.ToInt32(btnDeleteEvent.Attributes["data-id"]); // Find the record CalendarEvent calEvent = db.CalendarEvents.Find(id); // Remove the record db.CalendarEvents.Remove(calEvent); // Save to db db.SaveChanges(); // Create Notification string[] roleNamesArray = { calEvent.RoleName }; NotificationCreator.CreateNotification(roleNamesArray, "Event Deleted", calEvent.CalendarEventName, DateTime.Now, "Info", null, null); // Reset the modal controls ResetModalControls(); ResetButtons(false); PopulateCalendarData(); } catch (DataException dx) { LogFile.WriteToFile("EventManager.aspx.cs", "btnDeleteEvent_Click", dx, "An Event failed to be deleted", "HPSErrorLog.txt"); } }
// Update Contact & Hours Information protected void btnSaveAdminSettings_Click(object sender, EventArgs e) { ActivityTracker.Track("Administrator Settings Changed", (int)UserActionEnum.Updated); // Clear error label lblAdminSettingsErrors.Text = ""; // Load Administrator Settings Modal Data To Update it Contact info = db.Contacts.Find(1); // Contact Information info.Address = txtAddress.Text; info.Company = txtCompany.Text; info.Email = txtEmail.Text; info.Fax = txtFax.Text; info.Telephone = txtTelephone.Text; // Office Hours info.Monday = txtMonday.Text; info.Tuesday = txtTuesday.Text; info.Wednesday = txtWednesday.Text; info.Thursday = txtThursday.Text; info.Friday = txtFriday.Text; info.Saturday = txtSaturday.Text; info.Sunday = txtSunday.Text; // Banner Message info.BannerMessage = txtBanner.Text; info.BannerColor = colorPicker.Attributes["value"]; try { // Change the entry state db.Entry(info).State = System.Data.Entity.EntityState.Modified; // Save to DB db.SaveChanges(); // Create a notification for the database string[] role = { "Everyone" }; NotificationCreator.CreateNotification(role, "Information Updated", "Contact Info and Hours Changed", DateTime.Now, "Info", null, null); // To add new info to page Response.Redirect(Request.RawUrl); } catch (DataException dx) { // Display error to user and log it. lblAdminSettingsErrors.Text = "The changes you made failed to save, please try again.\nIf the problem persists contact the administrator."; LogFile.WriteToFile("HPFSMaster.Master.cs", "btnSaveAdminSettings_Click", dx, "Admin Settings Information change failed to save in db", "HPSErrorLog.txt"); } catch (Exception ex) { lblAdminSettingsErrors.Text = "The changes you made failed to save, please try again.\nIf the problem persists contact the administrator."; LogFile.WriteToFile("HPFSMaster.Master.cs", "btnSaveAdminSettings_Click", ex, "Admin Settings Information failed to update", "HPSErrorLog.txt"); } }
protected void btnContactSend_Click(object sender, EventArgs e) { ActivityTracker.Track("Sent Contact Email", (int)UserActionEnum.Created); // Create an info object to dynamically set email address Contact info = db.Contacts.Find(1); using (MailMessage mm = new MailMessage(ConfigurationManager.AppSettings["Email"], info.Email)) { mm.Subject = txtContactSubject.Text; mm.Body = "Reply Address: " + txtContactEmail.Text + "\n\n" + tarContactMessage.InnerText; mm.IsBodyHtml = false; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp-mail.outlook.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(ConfigurationManager.AppSettings["Email"], ConfigurationManager.AppSettings["Password"]); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; try { // Clear error label lblContactFormErrors.Text = ""; // try sending email smtp.Send(mm); // Create a notification for the database string[] role = { "Administrator" }; NotificationCreator.CreateNotification(role, "Contact Email Sent", "Subject: " + txtContactSubject.Text, DateTime.Now, "Info", null, null); // Alert user of success ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Your email has been successfully sent. We will get back to you as soon as possible.');", true); } catch (SmtpException se) { lblContactFormErrors.Text += "Email failed to send try again. You may have reached your daily limit. " + "If the problem persists contact your administrator."; LogFile.WriteToFile("HPFSMaster.Master.cs", "btnContactSend_Click", se, "Contact email failed to send.", "HPSErrorLog.txt"); } catch (Exception ex) { lblContactFormErrors.Text += " An error occured try again. If the problem persists contact your administrator.<br>"; LogFile.WriteToFile("HPFSMaster.Master.cs", "btnContactSend_Click", ex, "Error caused Contact email to fail.", "HPSErrorLog.txt"); } } }
public ActionResult Delete(int id) { using (var db = DbFactory.Open()) { var transaction = db.Load <Transaction>(id); db.Session.Save(NotificationCreator.ForDeletedTransaction(transaction)); db.Session.Delete(transaction); db.Commit(); Logger.I("Deleted transaction {0}", id); } return(Json(new { })); }
public ActionResult Create(TransactionRest transaction) { using (var db = DbFactory.Open()) { var dlTransaction = TransactionFromRest(transaction, db); db.Session.Save(dlTransaction); db.Session.Save(NotificationCreator.ForCreatedTransaction(dlTransaction)); db.Commit(); var response = new TransactionRest(dlTransaction); Logger.I("Created transaction {0}", response.ToJson()); return(Json(response)); } }
protected void btnSaveProgramData_Click(object sender, EventArgs e) { HelperMethods.ActivityTracker.Track("Program Information Updated", (int)UserActionEnum.Updated); lblProgramDataSuccess.Text = ""; lblProgramDataError.Text = ""; try { // Grab program data Program prog = db.Programs.Find(Convert.ToInt32(ddlSelectProgramTab.SelectedValue)); // Update Data prog.ProgramCoordinator = txtProgramCoordinator.Text; prog.ProgramDescription = txtProgramDescription.Text; prog.ProgramEmail = txtProgramEmail.Text; prog.ProgramGoals = txtProgramGoals.Text; prog.ProgramLocation = txtProgramLocation.Text; prog.ProgramPhone = txtProgramPhone.Text; prog.ProgramSchedule = txtProgramSchedule.Text.Replace("\n", "<br />"); prog.ProgramMap = (txtProgramMap.Text.StartsWith("h")) ? txtProgramMap.Text : txtProgramMap.Text.Split('"')[1]; // Change the entry state db.Entry(prog).State = System.Data.Entity.EntityState.Modified; // Save to DB db.SaveChanges(); // alert user of success lblProgramDataSuccess.Text = "Changes Saved."; // Create a notification for the database string[] role = { "Everyone" }; NotificationCreator.CreateNotification(role, "Program Updated:", prog.ProgramName, DateTime.Now, "Info", null, null); } catch (DataException dx) { LogFile.WriteToFile("ProgramManager.aspx.cs", "SaveSlideShow", dx, "An Administrator tried to update Program Information.", "HPSErrorLog.txt"); lblProgramDataError.Text = "Changes Failed to Save, try again."; } catch (Exception ex) { LogFile.WriteToFile("ProgramManager.aspx.cs", "SaveSlideShow", ex, "An Administrator tried to update Program Information.", "HPSErrorLog.txt"); lblProgramDataError.Text = "Changes Failed to Save, try again."; } }
public string DeleteUser(string id) { // Find the other half of the user in the aspnetuser table AspNetUser deletedUser = db.AspNetUsers.Find(id); // Get the user id thats currently logged in string userId = HttpContext.Current.Session["UserId"].ToString(); var user = db.HPSUsers.Select(u => u) .Where(uid => uid.UserId == userId) .SingleOrDefault(); try { // Remove the details from both users db.AspNetUsers.Remove(deletedUser); // Store deleted user name before the saving changes to add to notifcation creator string deletedUserName = deletedUser.UserName; // Only admins will see the users delete so hard code in the role required for this string[] roleArray = { "Administrator" }; // Save Changes to the database db.SaveChanges(); // Create a notification for the database NotificationCreator.CreateNotification(roleArray, "User Deleted", user.AspNetUser.UserName + " deleted the user named '" + deletedUserName + "'.", DateTime.Now, "Info", null, null); return(user.AspNetUser.UserName + " was successfully deleted."); } catch (DataException dx) { LogFile.WriteToFile("UserManager.asmx.cs", "DeleteUser", dx, "Webmethod failed to delete user from database", "HPSErrorLog.txt"); return("A data error occurred. " + user.AspNetUser.UserName + " could not be deleted at this time. Please try again later or inform an Administrator."); } catch (Exception ex) { LogFile.WriteToFile("UserManager.asmx.cs", "DeleteUser", ex, "Error when trying to delete user", "HPSErrorLog.txt"); return("An error occurred. " + user.AspNetUser.UserName + " could not be deleted at this time. Please try again later or inform an Administrator."); } }
protected void btnSaveEvent_Click(object sender, EventArgs e) { HelperMethods.ActivityTracker.Track("Saved an Edited Calendar Event", (int)UserActionEnum.Updated); try { // Get the record id from the button int id = Convert.ToInt32(btnSaveEvent.Attributes["data-id"]); // Find the record CalendarEvent calEvent = db.CalendarEvents.Find(id); // Update the information calEvent.CalendarEventName = txtEventName.Text; calEvent.CalendarEventDescription = txtEventDescription.Text; calEvent.CalendarEventDate = Convert.ToDateTime(txtEventDate.Text + " " + txtEventTime.Text); calEvent.RoleName = ddlVisibilty.SelectedValue; // Assign null if no file is selected int?noFileSelected = null; calEvent.FileId = (ddlEventFile.SelectedValue == "null") ? noFileSelected : Convert.ToInt32(ddlEventFile.SelectedValue); // Change the entry state db.Entry(calEvent).State = System.Data.Entity.EntityState.Modified; // Save to DB db.SaveChanges(); // Create Notification string[] roleNamesArray = { calEvent.RoleName }; NotificationCreator.CreateNotification(roleNamesArray, "Event Updated", calEvent.CalendarEventName, DateTime.Now, "Info", null, null); // Reset the modal controls ResetModalControls(); ResetButtons(false); PopulateCalendarData(); } catch (DataException dx) { LogFile.WriteToFile("EventManager.aspx.cs", "btnSaveEvent_Click", dx, "An Event failed to be updated", "HPSErrorLog.txt"); } }
public ActionResult Update(TransactionRest transaction) { if (!transaction.Id.HasValue) { Logger.I("Attempt to update transaction without id"); Response.StatusCode = 400; return(Json(new { Field = "Id", Message = "Missing Id" })); } using (var db = DbFactory.Open()) { var oldTransaction = db.Load <Transaction>(transaction.Id.Value); var newTransaction = TransactionFromRest(transaction, db); db.Session.Save(NotificationCreator.ForUpdatedTransaction(oldTransaction, newTransaction)); db.Session.Update(TransactionFromRest(transaction, db, oldTransaction)); db.Commit(); var response = new TransactionRest(newTransaction); Logger.I("Updated transaction {0}", response.ToJson()); return(Json(response)); } }
protected void btnSavePass_Click(object sender, EventArgs e) { HelperMethods.ActivityTracker.Track("Saved a Password Reset", (int)UserActionEnum.Updated); try { if (isPhone) { // Grab user with the phone entered AspNetUser user = db.AspNetUsers.Where(u => u.PhoneNumber == txtInfo.Text).SingleOrDefault(); // no need to check if the user exists again // Create UserManager UserManager <IdentityUser> userManager = new UserManager <IdentityUser>(new UserStore <IdentityUser>()); // Remove old pass and add new pass userManager.RemovePassword(user.Id); userManager.AddPassword(user.Id, txtPass.Text); db.SaveChanges(); // Create a notification for the database string[] role = { "Administrator" }; NotificationCreator.CreateNotification(role, "Password Reset:", user.UserName + " reset their password", DateTime.Now, "Info", null, null); ScriptManager.RegisterStartupScript(this, GetType(), "slideDiv", "$('#recReset').animate({" + "left: '250px'," + "opacity: '0'," + "width: '384px'" + "}, 300, function() {" + "$(this).hide();" + "$('#recComplete').fadeIn(300);" + "});" , true); } else // is Email { // Grab user with the email entered AspNetUser user = db.AspNetUsers.Where(u => u.Email == txtInfo.Text).SingleOrDefault(); // no need to check if the user exists again // Create UserManager UserManager <IdentityUser> userManager = new UserManager <IdentityUser>(new UserStore <IdentityUser>()); // Remove old pass and add new pass userManager.RemovePassword(user.Id); userManager.AddPassword(user.Id, txtPass.Text); db.SaveChanges(); // Create a notification for the database string[] role = { "Administrator" }; NotificationCreator.CreateNotification(role, "Password Reset:", user.UserName + " reset their password", DateTime.Now, "Info", null, null); ScriptManager.RegisterStartupScript(this, GetType(), "slideDiv", "$('#recReset').animate({" + "left: '250px'," + "opacity: '0'," + "width: '384px'" + "}, 300, function() {" + "$(this).hide();" + "$('#recComplete').fadeIn(300);" + "});" , true); } } catch (DataException dx) { lblErrors.Text += "An error occured when saving the password. Contact your administrator.<br>"; LogFile.WriteToFile("AccountRecovery.aspx.cs", "btnSavePass_Click", dx, "Data Error when updating password", "HPSErrorLog.txt"); } catch (Exception ex) { lblErrors.Text += "An error occured when saving the password. Contact your administrator.<br>"; LogFile.WriteToFile("AccountRecovery.aspx.cs", "btnSavePass_Click", ex, "Error when updating password.", "HPSErrorLog.txt"); } }
public static void DeleteFile(int id) { ActivityTracker.Track("Deleted a File", (int)UserActionEnum.Deleted); // Get all files attached to folder HPSFile file = db.HPSFiles.Find(id); // Hold the folder name in a variable before it gets deleted string folderName = file.Folder.FolderName; string roles = file.Folder.RoleName; string[] roleNamesArray = new string[1]; // Check for multiple roles there will always be at least 1 role if (roles.Contains(',')) { roleNamesArray = roles.Split(','); } else { roleNamesArray[0] = roles; } // Get the user id thats currently logged in string userId = HttpContext.Current.Session["UserId"].ToString(); var user = db.HPSUsers.Select(u => u) .Where(uid => uid.UserId == userId) .SingleOrDefault(); try { // Remove the file db.HPSFiles.Remove(file); // Save Changes to the database db.SaveChanges(); // Create a notification for the database NotificationCreator.CreateNotification(roleNamesArray, "File Deleted", user.AspNetUser.UserName + " deleted '" + file.FileName + "' from the " + folderName + " folder.", DateTime.Now, "Info", id, null); // Set the delete flag and refresh the page so we can rebuild the folders/files deleteClicked = true; // Set the notification notificationMessage = "'" + file.FileName + "' was successfully deleted."; notificationStyle = "text-success"; notification = true; } catch (DataException dx) { // Set the notification notificationMessage = "'" + file.FileName + " could not be deleted at this time. Please try again later or inform an Administrator."; notificationStyle = "text-danger"; notification = true; // Write error to log file Log File Writer LogFile.WriteToFile("FileManager.aspx.cs", "DeleteFile", dx, user.AspNetUser.UserName + "tried to delete a File named " + file.FileName, "HPSErrorLog.txt"); } catch (Exception ex) { // Set the notification notificationMessage = "'" + file.FileName + " could not be deleted at this time. Please try again later or inform an Administrator."; notificationStyle = "text-danger"; notification = true; // Write error to log file Log File Writer LogFile.WriteToFile("FileManager.aspx.cs", "DeleteFile", ex, user.AspNetUser.UserName + "tried to delete a File named " + file.FileName, "HPSErrorLog.txt"); } }
protected void btnCreateFolder_Click(object sender, EventArgs e) { ActivityTracker.Track("Created a new Folder", (int)UserActionEnum.Created); // Check for existing folder to prevent duplicates var checkExistingFolder = db.Folders.Where(f => f.FolderName == txtFolderName.Text); if (!checkExistingFolder.Any()) { // Create new instance of folder Folder folder = new Folder(); try { // Create variable to hold role names for trimming string roleNames = ""; // Loop through checkbox list and add roles to rolename in folder for (int i = 0; i < chkFolderPermissions.Items.Count; i++) { if (chkFolderPermissions.Items[i].Selected) { roleNames += chkFolderPermissions.Items[i].Value + ", "; } } // Trim the trailing and leading comma's and extra spaces char[] charsToTrim = { ',', ' ' }; folder.RoleName = roleNames.Trim(charsToTrim); folder.FolderName = txtFolderName.Text; // Add userid to folder to see who created it folder.UserId = Session["UserId"].ToString(); // Add new record to database and save db.Folders.Add(folder); db.SaveChanges(); // Hold the folder name in a variable before it gets added string folderName = folder.FolderName; string roles = folder.RoleName; string[] roleNamesArray = new string[1]; // Check for multiple roles there will always be at least 1 role if (roles.Contains(',')) { roleNamesArray = roles.Split(','); } else { roleNamesArray[0] = roles; } // Repopulate the notifications table string userId = HttpContext.Current.Session["UserId"].ToString(); var user = db.HPSUsers.Select(u => u) .Where(uid => uid.UserId == userId) .SingleOrDefault(); // Create a notification for the database NotificationCreator.CreateNotification(roleNamesArray, "Folder Created", user.AspNetUser.UserName + " created the " + folderName + " folder.", DateTime.Now, "Info", null, null); // Get the table from master page and repopulate Table table = (Table)Master.FindControl("tblNotifications"); TableBuilder.BuildNotificationTable(userId, table); // Rebuild folders BuildFolders(); // Rebuild modals to go with folders for CRUD BuildModals(); // Build the drop down lists PopulateFolderDropDownLists(); // Set the notification lblCRUDMessage.Text = folder.FolderName + " folder was successfully created.";; lblCRUDMessage.CssClass = "text-success";; } catch (DataException dx) { // Set the notification lblCRUDMessage.Text = folder.FolderName + " folder could not be created at this time. Please try again later or inform an Administrator."; lblCRUDMessage.CssClass = "text-danger"; // Write error to log file Log File Writer LogFile.WriteToFile("FileManager.aspx.cs", "btnCreateFolder_Click", dx, User.Identity.Name + "tried to create a Folder named " + txtFolderName.Text + ".", "HPSErrorLog.txt"); } catch (Exception ex) { // Set the notification lblCRUDMessage.Text = folder.FolderName + " folder could not be created at this time. Please try again later or inform an Administrator."; lblCRUDMessage.CssClass = "text-danger"; // Write error to log file Log File Writer LogFile.WriteToFile("FileManager.aspx.cs", "btnCreateFolder_Click", ex, User.Identity.Name + "tried to create a Folder named " + txtFolderName.Text + ".", "HPSErrorLog.txt"); } } else { // Set the error message and repopulate folders lblCRUDMessage.Text = txtFolderName.Text + " already exists. Please choose another name."; lblCRUDMessage.CssClass = "text-danger"; // Build the drop down list for folders in the modal PopulateFolderDropDownLists(); // Build folders BuildFolders(); // Build modals to go with folders for CRUD BuildModals(); } }
protected void btnCreateUser_Click(object sender, EventArgs e) { ActivityTracker.Track("Created a New User", (int)UserActionEnum.Created); try { // Create instance of role manager and store RoleStore <IdentityRole> roleStore = new RoleStore <IdentityRole>(); RoleManager <IdentityRole> roleMgr = new RoleManager <IdentityRole>(roleStore); if (!roleMgr.RoleExists(ddlRole.Text)) { IdentityResult roleResult = roleMgr.Create(new IdentityRole(ddlRole.Text)); } // Declare UserStore and UserManager UserStore <IdentityUser> userStore = new UserStore <IdentityUser>(); UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userStore); // Declare/create new user and store in manager object in the userstore IdentityUser user = new IdentityUser(txtUsername.Text); user.Email = txtEmail.Text; // Store result of user creation IdentityResult idResult = manager.Create(user, txtPassword.Text); // Check if user was created and added to role if (idResult.Succeeded) { // Add user to role IdentityResult userResult = manager.AddToRole(user.Id, ddlRole.SelectedValue); lblMessage.Text = "User " + user.UserName + " was created successfully!"; lblMessage.CssClass = "text-success"; // Add other user information to separate table HPSUser hpsUser = new HPSUser(); hpsUser.FirstName = txtUserFirstName.Text; hpsUser.LastName = txtUserLastName.Text; hpsUser.CreatedOn = DateTime.Now; hpsUser.UserId = user.Id; hpsUser.RoleName = ddlRole.SelectedValue; db.HPSUsers.Add(hpsUser); // Add empty row to db for fitbit to help with update if sign up date is on the same day as a synchronization db.Steps.AddOrUpdate(new Step { StepCount = 0, StepDate = DateTime.Now.AddDays(-28), UserId = user.Id }); db.Distances.AddOrUpdate(new Distance { DistanceCount = 0, DistanceDate = DateTime.Now.AddDays(-28), UserId = user.Id }); db.Minutes.AddOrUpdate(new Minute { MinuteCount = 0, MinuteDate = DateTime.Now.AddDays(-28), UserId = user.Id }); // create notification for admin users string[] role = { "Administrator" }; NotificationCreator.CreateNotification(role, "User Created", Page.User.Identity.Name + " created the user named '" + user.UserName + "'.", DateTime.Now, "Info", null, null); // Save changes tgo db db.SaveChanges(); } else { lblMessage.Text = idResult.Errors.FirstOrDefault(); } } catch (DataException dx) { lblMessage.Text = "A data error occured. Please try again later or contact your Administrator if this continues to happen."; LogFile.WriteToFile("UserManager.aspx.cs", "btnCreateUser_Click", dx, "Data error when creating user", "HPSErrorLog.txt"); } catch (Exception ex) { lblMessage.Text = "An error occured. Please try again later or contact your Administrator if this continues to happen."; LogFile.WriteToFile("UserManager.aspx.cs", "btnCreateUser_Click", ex, "Error when creating user", "HPSErrorLog.txt"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { ActivityTracker.Track("Submitted Feedback", (int)UserActionEnum.Created); // Clear error label lblFeedbackErrors.Text = ""; try { // declare variables int rec = Convert.ToInt32(radRec.SelectedValue); int nav = Convert.ToInt32(radNav.SelectedValue); int app = Convert.ToInt32(radAppear.SelectedValue); int acc = Convert.ToInt32(radAccess.SelectedValue); double avg = (Convert.ToDouble(rec) + Convert.ToDouble(nav) + Convert.ToDouble(app) + Convert.ToDouble(acc)) / 4; // Create new entry and build it var fb = new FeedBack(); fb.FeedBackAccRating = acc; fb.FeedBackAppRating = app; fb.FeedBackNavRating = nav; fb.FeedBackRecRating = rec; fb.FeedBackAvg = avg; fb.FeedBackDate = DateTime.Now.Date; fb.FeedBackComment = txtComment.InnerText; fb.FeedBackArea = ddlSiteArea.SelectedValue.ToString(); // Add item to db and save changes db.Feedbacks.Add(fb); db.SaveChanges(); // Create a notification for the database string[] role = { "Administrator" }; string comment = ""; if (txtComment.InnerText.Length >= 24) { comment = txtComment.InnerText.Substring(0, 24); } else { comment = txtComment.InnerText; } NotificationCreator.CreateNotification(role, "Feedback Submitted", "Comment: " + comment + "...", DateTime.Now, "Info", null, null); } catch (DataException dx) { // Display error to user and log it. lblFeedbackErrors.Text = "Your feedback failed to submit, please try again.\nIf the problem persists contact the administrator."; LogFile.WriteToFile("HPFSMaster.Master.cs", "btnSubmit_Click", dx, "Feedback failed to save in database", "HPSErrorLog.txt"); } catch (Exception ex) { lblFeedbackErrors.Text = "Your feedback failed to submit, please try again.\nIf the problem persists contact the administrator."; LogFile.WriteToFile("HPFSMaster.Master.cs", "btnSubmit_Click", ex, "Feedback failed to submit", "HPSErrorLog.txt"); } // reset feedback form values txtComment.Value = ""; radAccess.SelectedValue = "5"; radAppear.SelectedValue = "5"; radNav.SelectedValue = "5"; radRec.SelectedValue = "5"; }