Exemplo n.º 1
0
 public static ToffeeAppleProduct toProduct(IngredientsByCount ingredients)
 {
     return(new ToffeeAppleProduct
     {
         ApplesCount = ingredients.ApplesCount,
     });
 }
Exemplo n.º 2
0
 public static Either <Error, IngredientsByCount> Prep(IngredientsByCount ingredients)
 {
     return(new IngredientsByCount
     {
         AppleCount = ingredients.AppleCount.Trim(),
         ApplesCount = Convert.ToInt32(ingredients.AppleCount.Trim())
     });
 }
Exemplo n.º 3
0
        private Either <Error, IngredientsByCount> ToffeeAppleRequest(string appleCount)
        {
            Either <Error, IngredientsByCount> ingredients =
                new IngredientsByCount
            {
                AppleCount = appleCount
            };

            return(ingredients);
        }
Exemplo n.º 4
0
        public static Either <Error, IngredientsByCount> Validate(IngredientsByCount ingredients)
        {
            if (string.IsNullOrWhiteSpace(ingredients.AppleCount))
            {
                return(AppleCountIsEmptyError());
            }

            try
            {
                var appleCount = Convert.ToInt32(ingredients.AppleCount.Trim());
            }
            catch
            {
                return(AppleCountNaNError());
            }

            return(ingredients);
        }