protected void HandleResult(IVoidResult result) { if (!result.Succeed) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ConstructErrorMessages(result))); } }
protected IHttpActionResult ResultToHttpActionResult(IVoidResult result) { if (result.Succeed) { return(Ok()); } return(BadRequest(ConstructErrorMessages(result))); }
public async Task <ActionResult> Allow(AccessRightsIndexViewModel model) { if (!ModelState.IsValid) { await Initialize(model); return(View(model)); } IVoidResult result = null; if (model.Editor.ScheduleApplied) { if (TimeZoneInfo.FindSystemTimeZoneById(model.Editor.SchedulerTimeZone) == null) { ModelState.AddModelError("Editor_SchedulerTimeZone", "Invalid time zone"); } if (ModelState.IsValid) { result = await ScheduleAccess(model.Editor); } } else { result = await AllowPermanentAccess(model.Editor); } if (result != null && !result.Succeded) { ModelState.AddModelError(string.Empty, result.Fault.Summary); } if (!ModelState.IsValid) { await Initialize(model); return(View(model)); } return(RedirectToAction("Index")); }
private string ConstructErrorMessages(IVoidResult result) { return(string.Join("\r\n", result.Messages)); }