@*   Xafari Framework version : 17.2.3011.1336   *@

@using DevExpress.ExpressApp.Utils
@using DevExpress.Persistent.Validation
@using Xafari.Mvc

@helper  CreateErrorRow(string imageName, string message, string rowId)
{
	<tr id="@(rowId)">
		@if (!MvcApplicationStyleManager.IsNewStyle)
		{
			if (!string.IsNullOrEmpty(imageName))
			{
				<td class="ErrorImage" style="text-align: left; vertical-align: top">
					@Html.Xafari().ImageInfo(imageName).GetHtml()
				</td>
			}
			else
			{
				<td></td>
			}
		}
		<td class="ErrorLabel">
			@{
				string[] strArray = HttpUtility.HtmlEncode(message.Trim()).Split(new char[] { '\n' });
				string str = string.Join("<br>", strArray);

				this.ViewContext.Writer.Write(str);
			}
		</td>
	</tr>
}
 
@{
	var errorImageName = "Error";
	var pageError = MvcErrorHandling.Instance.GetPageError();

	ValidationException validationException = null;
	if (pageError != null) { validationException = pageError.Exception as ValidationException; }
}
<div>
	@if (pageError != null)
	{
		<table class="ErrorMessage">
			@if (validationException != null)
			{
				<tr id="Header">
					<td colspan="2">
						@(validationException.MessageHeader)
					</td>
				</tr>
				ValidationResultType[] typeArray = new ValidationResultType[3];
				typeArray[1] = ValidationResultType.Warning;
				typeArray[2] = ValidationResultType.Information;
				foreach (ValidationResultType type in typeArray)
				{
					string messages = validationException.GetMessages(type);
					if (!string.IsNullOrEmpty(messages))
					{
						@CreateErrorRow(type.ToString(), messages, type.ToString())
					}
				}
				if (validationException.Result.ValidationOutcome == ValidationOutcome.Warning)
				{
					<tr>
						<td></td>
						<td colspan="2">
							@Html.DevExpress().CheckBox(settings =>
							{
								settings.Name = "Ch";
								settings.Text = CaptionHelper.GetLocalizedText("Texts", "IgnoreWarning");

								//settings.Properties.ClientSideEvents.CheckedChanged = string.Format("function(s,e) {{ xafari.utils.post('{0}', {{ ignore: s.GetValue() }}); }}", this.Url.Action("IgnoreError", XafariRouteConfig.ApplicationController));

							}).GetHtml()
						</td>
					</tr>
				}
			}
			else
			{
				@CreateErrorRow(errorImageName, pageError.GetErrorMessage(), "Header")
			}

		</table>
	}
	@{ MvcErrorHandling.Instance.ClearPageError(); }
</div>