public class APIResult
{
public int errorCode { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string errorMessage { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public object messageData { get; set; }
public APIResult(int errorCode, string errorMessage, object data)
{
this.errorCode = errorCode;
this.errorMessage = errorMessage;
messageData = data;
}
}
public abstract class BaseAPIController : Controller
{
protected JsonResult ApiMessage(int errorCode, string errorMessage = null, object data = null)
{
return Json(new APIResult(errorCode, errorMessage, data));
}
}
// И пример использования
public YourController: BaseAPIController
{
public async Task<IActionResult> YourAction(int id)
{
return ApiMessage(0, data: new { id = id });
// Или
// return ApiMessage(-2, errorMessage: "Invalid request parameters");
}
}
public IHttpActionResult Get([FromUri] Payment payment)
bundles.Add(new ScriptBundle("~/bundles/js/jquery-pack")
.Include("~/Scripts/jquery-1.10.2.min.js",
"~/Scripts/jquery-ui.min.js"));
manager.DefaultAccountLockoutTimeSpan
после количества manager.MaxFailedAccessAttemptsBeforeLockout
неудачных попыток логина.