示例#1
0
        /// <summary>
        /// Validates the object
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static ValidationResponse ValidateRequest(SermonMessageRequest request)
        {
            if (request == null)
            {
                return(new ValidationResponse(true, SystemMessages.EmptyRequest));
            }

            // A/V urls, and PassageRef are allowed to be null, however others cannot
            if (request.Date == null)
            {
                return(new ValidationResponse(true, string.Format(SystemMessages.NullProperty, "Date")));
            }

            if (request.Speaker == null)
            {
                return(new ValidationResponse(true, string.Format(SystemMessages.NullProperty, "Speaker")));
            }

            if (request.Title == null)
            {
                return(new ValidationResponse(true, string.Format(SystemMessages.NullProperty, "Title")));
            }

            if (request?.AudioDuration <= 0)
            {
                return(new ValidationResponse(true, SystemMessages.AudioDurationTooShort));
            }

            return(new ValidationResponse("Success!"));
        }
示例#2
0
        /// <summary>
        /// Validates the request object
        /// </summary>
        /// <param name="request"></param>
        public static ValidationResponse ValidateRequest(UpdateMessagesInSermonSeriesRequest request)
        {
            if (request == null)
            {
                return(new ValidationResponse(true, SystemMessages.EmptyRequest));
            }

            if (request.Message == null)
            {
                return(new ValidationResponse(true, string.Format(SystemMessages.NullProperty, "Message")));
            }

            var messageValidationResponse = SermonMessageRequest.ValidateRequest(request.Message);

            if (messageValidationResponse.HasErrors)
            {
                return(new ValidationResponse(true, messageValidationResponse.ErrorMessage));
            }

            return(new ValidationResponse("Success!"));
        }
        /// <summary>
        /// Validate the request object
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static ValidationResponse ValidateRequest(AddMessagesToSeriesRequest request)
        {
            if (request == null)
            {
                return(new ValidationResponse(true, SystemMessages.EmptyRequest));
            }

            if (request.MessagesToAdd == null)
            {
                return(new ValidationResponse(true, string.Format(SystemMessages.NullProperty, "MessagesToAdd")));
            }

            foreach (var message in request.MessagesToAdd)
            {
                var validateMessages = SermonMessageRequest.ValidateRequest(message);
                if (validateMessages.HasErrors)
                {
                    return(new ValidationResponse(true, validateMessages.ErrorMessage));
                }
            }

            return(new ValidationResponse("Success!"));
        }