public static Result <ProductCode> ToProductCode(string code)
        {
            var gizmoCodeResult  = GizmoCode.Of(code);
            var widgetCodeResult = WidgetCode.Of(code);

            return((gizmoCodeResult.Success, widgetCodeResult.Success) switch
            {
                (true, false) => Result <ProductCode> .Ok(gizmoCodeResult.Data),
                (false, true) => Result <ProductCode> .Ok(widgetCodeResult.Data),
                _ => Result <ProductCode> .Fail(new ValidationError("Invalid Product Code"))
            });
Ejemplo n.º 2
0
        private static async Task <Result <ProductCode[]> > MockProductCode()
        {
            await Task.Yield();

            return(Result <ProductCode[]> .Ok(new ProductCode[]
            {
                GizmoCode.Of("G124KC").Data,
                WidgetCode.Of("W1234DKC").Data,
                WidgetCode.Of("W1234DKZ").Data,
                WidgetCode.Of("W1244DKZ").Data,
                GizmoCode.Of("G125KC").Data,
            }));
        }