/// <summary>
		/// Adds the error message.
		/// </summary>
		/// <param name="message">The message.</param>
		/// <param name="fieldName">Name of the field.</param>
		/// <param name="value">The value.</param>
		/// <returns></returns>
		public static ClientErrorHandling AddErrorMessage(string message, string fieldName = "", string value = "")
		{
			var error = new ClientErrorHandling {Message = message, FieldName = fieldName, Value = value};
			List<ClientErrorHandling> currentErrors = GetErrorMessages();
			currentErrors.Add(error);
			SetErrorMessages(currentErrors);
			return error;
		}
		/// <summary>
		/// Sets the original clear error message.
		/// </summary>
		/// <param name="hasNoError">if set to <c>true</c> [has no error].</param>
		/// <param name="message">The message.</param>
		/// <param name="fieldName">Name of the field.</param>
		/// <param name="value">The value.</param>
		/// <returns></returns>
		public static ClientErrorHandling SetOrClearErrorMessage(bool hasNoError, string message, string fieldName, string value)
		{
			var error = new ClientErrorHandling {Message = message, FieldName = fieldName, Value = value};
			List<ClientErrorHandling> currentErrors = GetErrorMessages();
			currentErrors.RemoveAll(err => err.FieldName == fieldName && err.Message == message);
			if (!hasNoError)
				currentErrors.Add(error);
			SetErrorMessages(currentErrors);
			return hasNoError ? null : error;
		}
Esempio n. 3
0
        /// <summary>
        /// Adds the error message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public static ClientErrorHandling AddErrorMessage(string message, string fieldName = "", string value = "")
        {
            var error = new ClientErrorHandling {
                Message = message, FieldName = fieldName, Value = value
            };
            List <ClientErrorHandling> currentErrors = GetErrorMessages();

            currentErrors.Add(error);
            SetErrorMessages(currentErrors);
            return(error);
        }
Esempio n. 4
0
        /// <summary>
        /// Sets the original clear error message.
        /// </summary>
        /// <param name="hasNoError">if set to <c>true</c> [has no error].</param>
        /// <param name="message">The message.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public static ClientErrorHandling SetOrClearErrorMessage(bool hasNoError, string message, string fieldName, string value)
        {
            var error = new ClientErrorHandling {
                Message = message, FieldName = fieldName, Value = value
            };
            List <ClientErrorHandling> currentErrors = GetErrorMessages();

            currentErrors.RemoveAll(err => err.FieldName == fieldName && err.Message == message);
            if (!hasNoError)
            {
                currentErrors.Add(error);
            }
            SetErrorMessages(currentErrors);
            return(hasNoError ? null : error);
        }