public static GenericResult <TResult> GetUserSafeResult <TResult, TEntry>(this GenericResult <TEntry> entry, TResult result = default(TResult), string baseMsg = "") { if (entry.IsSucceed) { return(GenericResult <TResult> .Success(result, baseMsg)); } if (entry.EnumResultType == EnumResultType.UserSafeError) { return(GenericResult <TResult> .UserSafeError(result, baseMsg + " " + entry.GetAllMessage())); } return(GenericResult <TResult> .UserSafeError(result, baseMsg)); }
public static GenericResult <TResult> ConvertTo <TResult, TEntry>(this GenericResult <TEntry> entry, TResult result, string baseMsg = "") { var msg = baseMsg + " " + entry.GetAllMessage(); switch (entry.EnumResultType) { case EnumResultType.Success: return(GenericResult <TResult> .Success(result, baseMsg + " " + entry.GetAllMessage(false))); case EnumResultType.Error: return(GenericResult <TResult> .Error(result, msg)); case EnumResultType.Warning: return(GenericResult <TResult> .Warning(result, msg)); case EnumResultType.UserSafeError: return(GenericResult <TResult> .UserSafeError(result, msg)); default: return(GenericResult <TResult> .Error(result, msg)); } }