/// <summary> /// Checks if the input message is valid /// </summary> /// <returns>The validity of the input</returns> private ValidityResult IsInputValid() { ValidityResult result = new ValidityResult() { Valid = true }; // Check if a recipient was selected if (SelectedRecipient == NOT_ASSIGNED) { result.Valid = false; result.ErrorReport = "לא נבחר למי לשלוח את ההודעה"; } else if (MessageTitle == string.Empty) { result.Valid = false; result.ErrorReport = "לא הוזנה כותרת להודעה"; } else if (MessageText == string.Empty) { result.Valid = false; result.ErrorReport = "לא הוזן תוכן להודעה"; } return(result); }
/// <summary> /// Checks if the input for the event is valid /// </summary> /// <returns>The validity of the input</returns> private ValidityResult IsInputValid() { ValidityResult result = new ValidityResult() { Valid = true }; // Check if a recipient was selected if (SelectedRecipient == NOT_ASSIGNED) { result.Valid = false; result.ErrorReport = "לא נבחר למי לשלוח את האירוע"; } else if (EventDatetime == null) { result.Valid = false; result.ErrorReport = "לא הוזן תאריך לאירוע"; } else if (EventName == string.Empty) { result.Valid = false; result.ErrorReport = "לא הוזנה כותרת לאירוע"; } else if (EventText == string.Empty) { result.Valid = false; result.ErrorReport = "לא הוזן תוכן לאירוע"; } return(result); }
/// <summary> /// Assistant method to check the validity of the username and password. /// </summary> /// <param name="username">The Username to check</param> /// <param name="password">Secured version of the Password to check</param> /// <returns>The validity tests result</returns> private ValidityResult CheckLoginInputValidity(string username, SecureString password) { ValidityResult result = new ValidityResult(); result.Valid = true; // Did the user write a username if (username == null || username.Length == 0) { result.ErrorReport = "אנא הכנס שם משתמש"; result.Valid = false; } // Is the username valid else if (username.Length < Globals.MINIMUM_USERNAME_LENGTH || username.Length > Globals.MAXIMUM_USERNAME_LENGTH) { result.ErrorReport = string.Format("שם משתמש לא תקין. אורך שם המשתמש חייב להיות בין {0} לבין {1} תווים", Globals.MINIMUM_USERNAME_LENGTH, Globals.MAXIMUM_USERNAME_LENGTH); result.Valid = false; } // Did the user write a password else if (password == null || password.Length == 0) { result.ErrorReport = "אנא הכנס סיסמא"; result.Valid = false; } // Is the password valid else if (password.Length < Globals.MINIMUM_PASSWORD_LENGTH || password.Length > Globals.MAXIMUM_PASSWORD_LENGTH) { result.ErrorReport = string.Format("סיסמא לא תקינה. אורך הסיסמא חייב להיות בין {0} לבין {1} תווים", Globals.MINIMUM_PASSWORD_LENGTH, Globals.MAXIMUM_PASSWORD_LENGTH); result.Valid = false; } return(result); }
/// <summary> /// Create a new event with the current data and send it /// </summary> private void CreateNewEvent() { ValidityResult inputValid = IsInputValid(); if (inputValid.Valid) { // Create a new event Event newEvent = new Event() { eventDate = EventDatetime, location = EventLocation, name = EventName, description = EventText, submitterID = ConnectedPerson.personID }; SetEventRecipients(newEvent); // Save the event _schoolData.Events.Add(newEvent); _schoolData.SaveChanges(); // Report success SendMessageAboutEvent(newEvent, ActionOnEvent.Created); _messageBoxService.ShowMessage("אירוע נוצר בהצלחה ונשלח ל" + Recipients[SelectedRecipient], "נשלח אירוע", MessageType.OK_MESSAGE, MessagePurpose.INFORMATION); // Update all data _refreshDataCommand.Execute(null); } else { _messageBoxService.ShowMessage(inputValid.ErrorReport, "נכשל ביצירת אירוע", MessageType.OK_MESSAGE, MessagePurpose.ERROR); } }
/// <summary> /// Helper method for the registration. Checks if the input is valid /// </summary> /// <returns></returns> private ValidityResult CheckInputValidity() { ValidityResult result = new ValidityResult(); result.Valid = true; // Make sure at least one user type was chosen if (!IsStudent && !IsParent && !IsTeacher && !IsSecretary && !IsPrincipal) { result.ErrorReport = "אנא בחר סוג משתמש"; result.Valid = false; } // Student must be in a class else if (IsStudent && (SelectedClass == null || SelectedClass == FIELD_NOT_SET)) { result.ErrorReport = "אנא בחר כיתה לתלמיד"; result.Valid = false; } // Parent must have a child else if (IsParent && (SelectedStudent == null || SelectedStudent == FIELD_NOT_SET)) { result.ErrorReport = "אנא בחר את הילד של ההורה"; result.Valid = false; } else if (IsTeacher && (SelectedCourse1 == null || SelectedCourse1 == FIELD_NOT_SET)) { result.ErrorReport = "אנא בחר מקצוע אחד לפחות למורה"; result.Valid = false; } return(result); }
/// <summary> /// Helper method for the registration. Checks if the input is valid /// </summary> /// <returns></returns> private ValidityResult CheckInputValidity() { ValidityResult result = new ValidityResult(); result.Valid = true; // Check that a username was written if (Username == null || Username.Length == 0) { result.ErrorReport = "אנא הכנס שם משתמש"; result.Valid = false; } // Is the username valid else if (Username.Length < Globals.MINIMUM_USERNAME_LENGTH || Username.Length > Globals.MAXIMUM_USERNAME_LENGTH) { result.ErrorReport = string.Format("שם משתמש לא תקין. אורך שם המשתמש חייב להיות בין {0} לבין {1} תווים", Globals.MINIMUM_USERNAME_LENGTH, Globals.MAXIMUM_USERNAME_LENGTH); result.Valid = false; } // Make sure that last name was written else if (FirstName == null || FirstName.Length == 0) { result.ErrorReport = "אנא הכנס שם פרטי"; result.Valid = false; } // Make sure that last name was written else if (LastName == null || LastName.Length == 0) { result.ErrorReport = "אנא הכנס שם משפחה"; result.Valid = false; } // Make sure at least one user type was chosen else if (!IsNewStudent && !IsNewParent && !IsNewTeacher && !IsNewSecretary) { result.ErrorReport = "אנא בחר סוג משתמש"; result.Valid = false; } // Student must be in a class else if (IsNewStudent && (SelectedClass == null || SelectedClass == FIELD_NOT_SET)) { result.ErrorReport = "אנא בחר כיתה לתלמיד"; result.Valid = false; } // Parent must have a child else if (IsNewParent && (SelectedStudent == null || SelectedStudent == FIELD_NOT_SET)) { result.ErrorReport = "אנא בחר את הילד של ההורה"; result.Valid = false; } else if (IsNewTeacher && (SelectedCourse1 == null || SelectedCourse1 == FIELD_NOT_SET)) { result.ErrorReport = "אנא בחר מקצוע אחד לפחות למורה"; result.Valid = false; } return(result); }
public ValidityResult IsValidPosition(EdtrisPiece piece, int colOffset, int rowOffset) { piece.col += colOffset; piece.row += rowOffset; ValidityResult result = IsValidPosition(piece); piece.col -= colOffset; piece.row -= rowOffset; return(result); }
/// <summary> /// Create a new message with the current data and send it /// </summary> private void CreateNewMessage() { ValidityResult inputValid = IsInputValid(); if (inputValid.Valid) { // Create a message depending on selected recipient category // Check first the options to send a message to everyone from a specific group if (SendingToStudent && SelectedRecipient == EVERYONE_OPTION) { MessagesHandler.CreateMessage(MessageTitle, MessageText, MessageRecipientsTypes.Students, ConnectedPerson.personID); } else if (SendingToTeacher && SelectedRecipient == EVERYONE_OPTION) { MessagesHandler.CreateMessage(MessageTitle, MessageText, MessageRecipientsTypes.Teachers, ConnectedPerson.personID); } else if (SendingToManagement && SelectedRecipient == EVERYONE_OPTION) { MessagesHandler.CreateMessage(MessageTitle, MessageText, MessageRecipientsTypes.Management, ConnectedPerson.personID); } else if (SendingToEveryone) { MessagesHandler.CreateMessage(MessageTitle, MessageText, MessageRecipientsTypes.Everyone, ConnectedPerson.personID); } // Handle messages for a specific class else if (SendingToClass) { MessagesHandler.CreateMessage(MessageTitle, MessageText, MessageRecipientsTypes.Class, ConnectedPerson.personID, SelectedRecipient); } // All other messages are aimed for a specific person else { MessagesHandler.CreateMessage(MessageTitle, MessageText, MessageRecipientsTypes.Person, ConnectedPerson.personID, SelectedRecipient); } // Report success _messageBoxService.ShowMessage("הודעה נוצרה בהצלחה ונשלחה ל" + Recipients[SelectedRecipient], "נשלחה הודעה", MessageType.OK_MESSAGE, MessagePurpose.INFORMATION); // Update all data _refreshDataCommand.Execute(null); } else { _messageBoxService.ShowMessage(inputValid.ErrorReport, "נכשל ביצירת הודעה", MessageType.OK_MESSAGE, MessagePurpose.ERROR); } }
/// <summary> /// Update the currently selected event /// </summary> private void UpdateSelectedEvent() { // Check that an event was selected if (SelectedEvent != null) { // Check the input validity was selected ValidityResult inputValid = IsInputValid(); if (inputValid.Valid) { // Get the event that is going to be edited Event selectedEvent = _schoolData.Events.Find(SelectedEvent.ID); // Update the event's data selectedEvent.submitterID = ConnectedPerson.personID; selectedEvent.eventDate = EventDatetime; selectedEvent.location = EventLocation; selectedEvent.name = EventName; selectedEvent.description = EventText; SetEventRecipients(selectedEvent); // Update the model _schoolData.SaveChanges(); // Report action success SendMessageAboutEvent(selectedEvent, ActionOnEvent.Updated); _messageBoxService.ShowMessage("האירוע עודכן בהצלחה!", "עודכן אירוע", MessageType.OK_MESSAGE, MessagePurpose.INFORMATION); // Update data in all screens _refreshDataCommand.Execute(null); } else { _messageBoxService.ShowMessage(inputValid.ErrorReport, "נכשל בעדכון אירוע", MessageType.OK_MESSAGE, MessagePurpose.ERROR); } } else { _messageBoxService.ShowMessage("אנא בחר אירוע קודם כל.", "נכשל בעדכון אירוע", MessageType.OK_MESSAGE, MessagePurpose.ERROR); } }
public void displayMessage(IDataValue value, ValidityResult result) { }