/// <summary> /// Validates status of feedback. /// </summary> /// <param name="status">Feedback status for validation.</param> /// <param name="newStatus">Feedback's new status for validation.</param> /// <returns>Validity of status.</returns> public static bool ValidateStatus(FeedbackStatusEnum status, FeedbackStatusEnum newStatus) { if (status == FeedbackStatusEnum.Answered) { return((int)newStatus < (int)status); } return((status != FeedbackStatusEnum.New) && (int)newStatus <= (int)status); }
/// <summary> /// Change status of the feedback /// </summary> /// <param name="feedback">id for reply.</param> /// <param name="newStatusCode">Information about mail (body, receiver)</param> private void ChangeFeedbackStatus(Feedback feedback, FeedbackStatusEnum newStatusCode) { feedback.Status = newStatusCode; if (ShouldChangeLastUpdateInfo(newStatusCode)) { int userId = _currentUserService.GetCurrentUserId(); User user = _userService.GetUser(userId); feedback.UpdateDate = TimeProvider.Current.UtcNow; feedback.AdminName = user.PersonName; } _feedbackRepository.Update(feedback); _feedbackRepository.UnitOfWork.Commit(); }
private bool ShouldChangeLastUpdateInfo(FeedbackStatusEnum newStatusCode) { return(newStatusCode == FeedbackStatusEnum.Closed || newStatusCode == FeedbackStatusEnum.Answered); }
/// <summary> /// Sets the feedback status /// </summary> /// <param name="status">Feedback status</param> /// <returns>Feedback object</returns> public FeedbackBuilder WithStatus(FeedbackStatusEnum status) { _feedback.Status = status; return(this); }