public void RaisePostBackEvent(string eventArgument) { var action = eventArgument.Split('|')[0]; var argument = eventArgument.Split('|')[1]; var service = new MessagesService(); switch(action) { case "viewmessage": service.UpdateEmailsStatus(new int[] {Convert.ToInt32(argument)}, MailStatusType.Read); Response.Redirect("ViewMessage.aspx?id=" + argument); break; case "markallasread": var allIDs = service.GetAllEmailIDs(MailStatusType.New, FolderID).ToArray(); service.UpdateEmailsStatus(allIDs, MailStatusType.Read); Response.Redirect(Request.Url.AbsoluteUri); break; case "markselectedasread": if(string.IsNullOrEmpty(argument)) return; var idsToBeMarkedAsRead = Array.ConvertAll(argument.Split(','), s => int.Parse(s)); service.UpdateEmailsStatus(idsToBeMarkedAsRead, MailStatusType.Read); Response.Redirect(Request.Url.AbsoluteUri); break; case "markselectedasunread": if(string.IsNullOrEmpty(argument)) return; var idsToBeMarkedAsUnread = Array.ConvertAll(argument.Split(','), s => int.Parse(s)); service.UpdateEmailsStatus(idsToBeMarkedAsUnread, MailStatusType.New); Response.Redirect(Request.Url.AbsoluteUri); break; case "movetodeleted": if(string.IsNullOrEmpty(argument)) return; var idsToMoveToDeleted = Array.ConvertAll(argument.Split(','), s => int.Parse(s)); service.MoveEmails(idsToMoveToDeleted, 4); Response.Redirect(Request.Url.AbsoluteUri); break; case "deletedrafts": if(string.IsNullOrEmpty(argument)) return; var draftsToPermanentlyDelete = Array.ConvertAll(argument.Split(','), s => int.Parse(s)); service.PermanentlyDeleteEmails(draftsToPermanentlyDelete); Response.Redirect(Request.Url.AbsoluteUri); break; case "deleteemails": if(string.IsNullOrEmpty(argument)) return; var idsToPermanentlyDelete = Array.ConvertAll(argument.Split(','), s => int.Parse(s)); service.PermanentlyDeleteEmails(idsToPermanentlyDelete); Response.Redirect(Request.Url.AbsoluteUri); break; case "emptytrash": var allTrashIDs = service.GetAllEmailIDs(FolderID).ToArray(); service.PermanentlyDeleteEmails(allTrashIDs); Response.Redirect(Request.Url.AbsoluteUri); break; case "movetofolder": var moveToFolderID = Convert.ToInt32(argument); var idsToMove = Array.ConvertAll(eventArgument.Split('|')[2].Split(','), s => int.Parse(s)); service.MoveEmails(idsToMove, moveToFolderID); Response.Redirect(Request.Url.AbsoluteUri); break; case "movetonewfolder": var newFolderDescription = argument; var idsToMoveToNewFolder = Array.ConvertAll(eventArgument.Split('|')[2].Split(','), s => int.Parse(s)); // First, create the new folder. var newFolderID = service.CreatePersonalEmailFolder(newFolderDescription); // Next, move the selected emails to the new folder. service.MoveEmails(idsToMoveToNewFolder, newFolderID); Response.Redirect(Request.Url.AbsoluteUri); break; } }
public void RaisePostBackEvent(string eventArgument) { var action = eventArgument.Split('|')[0]; var argument = eventArgument.Split('|')[1]; var service = new MessagesService(); switch(action) { case "reply": break; case "forward": break; case "markselectedasunread": if(string.IsNullOrEmpty(argument)) return; var idsToBeMarkedAsUnread = Array.ConvertAll(argument.Split(','), s => int.Parse(s)); service.UpdateEmailsStatus(idsToBeMarkedAsUnread, MailStatusType.New); Response.Redirect("Messages.aspx"); break; case "movetodeleted": if(string.IsNullOrEmpty(argument)) return; var idsToMoveToDeleted = Array.ConvertAll(argument.Split(','), s => int.Parse(s)); service.MoveEmails(idsToMoveToDeleted, 4); Response.Redirect("Messages.aspx"); break; case "movetofolder": var moveToFolderID = Convert.ToInt32(argument); var idsToMove = Array.ConvertAll(eventArgument.Split('|')[2].Split(','), s => int.Parse(s)); service.MoveEmails(idsToMove, moveToFolderID); Response.Redirect("Messages.aspx"); break; case "movetonewfolder": var newFolderDescription = argument; var idsToMoveToNewFolder = Array.ConvertAll(eventArgument.Split('|')[2].Split(','), s => int.Parse(s)); // First, create the new folder. var newFolderID = service.CreatePersonalEmailFolder(newFolderDescription); // Next, move the selected emails to the new folder. service.MoveEmails(idsToMoveToNewFolder, newFolderID); Response.Redirect("Messages.aspx"); break; } }