public static ActionTaskResult Error(ActionTaskResultMessage message, int[] failedIds = null) { var result = new ActionTaskResult { IsSuccess = false, FailedIds = failedIds }; result.Messages.Add(message); return(result); }
public static ActionTaskResult Success(ActionTaskResultMessage message) { var result = new ActionTaskResult { IsSuccess = true }; result.Messages.Add(message); return(result); }
public static ActionTaskResult PartialSuccess(ActionTaskResultMessage message, int[] failedIds) { var result = new ActionTaskResult { IsSuccess = true, FailedIds = failedIds }; result.Messages.Add(message); return(result); }
public static ActionTaskResultMessage FromString(string str) { ActionTaskResultMessage result = null; try { result = JsonConvert.DeserializeObject <ActionTaskResultMessage>(str); } catch (Exception) { result = new ActionTaskResultMessage() { Message = str }; } return(result); }
public static ActionTaskResult FromRulesException(RulesException ex, int id) { var result = new ActionTaskResult() { IsSuccess = true }; if (!ex.IsEmpty) { result.IsSuccess = false; var messages = ex.Errors .Select(s => ActionTaskResultMessage.FromString(s.Message)).ToArray(); foreach (var message in messages) { message.Extra = id.ToString(); result.Messages.Add(message); } } return(result); }