private ActionResponse ParseModelStateErrorToActionResponse(ModelStateDictionary modelState) { var response = new ActionResponse(HttpStatusCode.BadRequest, ActionResponseStatusType.Error); var errorList = modelState .Where(x => x.Value.Errors.Count > 0) .ToDictionary( entry => entry.Key, entry => entry.Value.Errors.Select(e => e.ErrorMessage).ToArray()); foreach (var error in errorList) { response.AddErrors(error.Key, error.Value); } return(response); }