public void OnException(ExceptionContext context) { if (!_operationResult.HasErrors) { _operationResult.AddError(MessageCodes.Error, null, false); } context.Result = new ObjectResult(_operationResult.Errors); context.HttpContext.Response.StatusCode = 400; }
public static void Validate(LinkEntry entry, IOperationResult operationResult) { if (entry.IpAdress.Length > 50) { operationResult.AddError(LinkEntryErrors.longIpAddressMessage); } if (!string.IsNullOrEmpty(entry.URL)) { if (entry.URL.Length > 2000) { operationResult.AddError(LinkEntryErrors.longUrlErrorMessage); } if (!UrlValidator.ValidHttpURL(entry.URL)) { operationResult.AddError(LinkEntryErrors.invalidUrl); } } else { operationResult.AddError(LinkEntryErrors.missingUrl); } }