Esempio n. 1
0
        public async Task <IActionResult> Get()

        {
            using (SqlConnection conn = Connection)
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = @"
                        SELECT *
                        FROM BrewMethod
                        WHERE 1 = 1 
                        ";


                    SqlDataReader reader = cmd.ExecuteReader();

                    List <BrewMethod> allBrewMethods = new List <BrewMethod>();

                    while (reader.Read())
                    {
                        var brewMethod = new BrewMethod()
                        {
                            Id          = reader.GetInt32(reader.GetOrdinal("Id")),
                            Method      = reader.GetString(reader.GetOrdinal("Method")),
                            PaperFilter = reader.GetBoolean(reader.GetOrdinal("PaperFilter")),
                            BrewType    = reader.GetString(reader.GetOrdinal("BrewType")),
                        };
                        if (!reader.IsDBNull(reader.GetOrdinal("ImagePath")))
                        {
                            brewMethod.ImagePath = reader.GetString(reader.GetOrdinal("ImagePath"));
                        }
                        else
                        {
                            brewMethod.ImagePath = null;
                        }

                        allBrewMethods.Add(brewMethod);
                    }
                    reader.Close();

                    return(Ok(allBrewMethods));
                }
            }
        }
        public ActionResult <string> Get(BrewMethod brewMethod = BrewMethod.Drip)
        {
            Beverage beverage;

            switch (brewMethod)
            {
            case BrewMethod.Espresso:
                beverage = new Beverage
                {
                    BrewMethod = BrewMethod.Espresso,
                    IsBrewing  = true
                };
                break;

            case BrewMethod.FrenchPress:
                beverage = new Beverage
                {
                    BrewMethod = BrewMethod.FrenchPress,
                    IsBrewing  = true
                };
                break;

            case BrewMethod.PourOver:
                beverage = new Beverage
                {
                    BrewMethod = BrewMethod.PourOver,
                    IsBrewing  = true
                };
                break;

            case BrewMethod.Drip:
            default:
                beverage = new Beverage
                {
                    BrewMethod = BrewMethod.Drip,
                    IsBrewing  = true
                };
                break;
            }
            return(beverage?.ToString());
        }
        public ActionResult <string> Get(BrewMethod brewMethod = BrewMethod.Drip)
        {
            switch (brewMethod)
            {
            case BrewMethod.Espresso:
                _coffeeContext.SetCoffeeStrategy(new EspressoStrategy());
                break;

            case BrewMethod.FrenchPress:
                _coffeeContext.SetCoffeeStrategy(new FrenchPressStrategy());
                break;

            case BrewMethod.PourOver:
                _coffeeContext.SetCoffeeStrategy(new PourOverStrategy());
                break;

            case BrewMethod.Drip:
            default:
                _coffeeContext.SetCoffeeStrategy(new DripStrategy());
                break;
            }
            return(_coffeeContext.Brew().ToString());
        }
Esempio n. 4
0
        public async Task <IActionResult> Get([FromRoute] int id)
        {
            using (SqlConnection conn = Connection)
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = @"
                        SELECT * 
                        FROM BrewMethod 
                        WHERE Id = @id";
                    cmd.Parameters.Add(new SqlParameter("@id", id));
                    SqlDataReader reader = cmd.ExecuteReader();

                    BrewMethod brewMethod = null;

                    if (reader.Read())
                    {
                        brewMethod = new BrewMethod()
                        {
                            Id          = reader.GetInt32(reader.GetOrdinal("Id")),
                            Method      = reader.GetString(reader.GetOrdinal("Method")),
                            PaperFilter = reader.GetBoolean(reader.GetOrdinal("PaperFilter")),
                            BrewType    = reader.GetString(reader.GetOrdinal("BrewType"))
                        };

                        reader.Close();

                        return(Ok(brewMethod));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
            }
        }
Esempio n. 5
0
        public ActionResult <string> Get(BrewMethod brewMethod = BrewMethod.Drip)
        {
            _coffeeContext.SetCoffeeStrategy(brewMethod);

            return(_coffeeContext.Brew().ToString());
        }
Esempio n. 6
0
 public BarleyWine(string name, double batchvolume, BrewMethod brewMethod, double IBUs) : base(name, batchvolume, brewMethod, IBUs)
 {
     throw new NotImplementedException();
 }
Esempio n. 7
0
 public Lager(string name, double batchvolume, BrewMethod brewMethod, double IBUs, string bottleType, int bottleVol) : base(name, batchvolume, brewMethod, IBUs)
 {
     BeerType     = _beerType;
     BottleType   = bottleType;
     BottleVolume = bottleVol;
 }
Esempio n. 8
0
 //Constructor for beer requires multiple brewing methods
 public FermentedProducts(string name, double batchVolume, BrewMethod brewMethod)
 {
     Name          = name;
     BatchVolume   = batchVolume;
     CurrentMethod = brewMethod;
 }
Esempio n. 9
0
 public void SetCoffeeStrategy(BrewMethod method)
 {
     _coffeeStrategy = _coffeeStrategies.FirstOrDefault(c => c.Method == method) ?? throw new ArgumentException($"Invalid {nameof(method)}");
 }
Esempio n. 10
0
 public Beer(string name, double batchvolume, BrewMethod brewMethod, double IBUs) : base(name, batchvolume, brewMethod)
 {
     IBUvalue              = IBUs;
     BeerEquipExtractList  = new List <string>();
     BeerEquipAllGrainList = new List <string>();
 }