public async Task <IActionResult> Create([Bind("Address,Name")] TemperatureSensor temperatureSensor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(temperatureSensor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(temperatureSensor));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("ID,Amount")] GrainRecipeItem grainRecipeItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(grainRecipeItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(grainRecipeItem));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("RecipeID,RecipeName,StyleName,TargetGravity,MashingTemp,SuggestedFermTemp")] Recipe recipe)
        {
            if (ModelState.IsValid)
            {
                _context.Add(recipe);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StyleName"] = new SelectList(_context.Styles, "StyleName", "StyleName", recipe.StyleName);
            return(View(recipe));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("BeerID,RecipeName,RecipeID,ABV,BrewDate,RackDate,KegDate,InitalGravity,FinalGravity,Description,Active")] Beer beer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(beer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RecipeID"] = new SelectList(_context.RecipeCatalog, "RecipeID", "RecipeID", beer.RecipeID);
            return(View(beer));
        }
        public async Task <IActionResult> Create([Bind("FermenterID,Name,TargetTemp,BeerID,Address")] Fermenter fermenter)
        {
            if (ModelState.IsValid)
            {
                fermenter.Wort = await _context.BrewHistory.SingleOrDefaultAsync(x => x.BeerID == fermenter.BeerID);

                fermenter.TempSensor = await _context.Sensors.SingleOrDefaultAsync(x => x.Address == fermenter.Address);

                _context.Fermenters.Add(fermenter);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Address"] = new SelectList(_context.Sensors, "Address", "Address", fermenter.Address);
            ViewData["BeerID"]  = new SelectList(_context.BrewHistory, "BeerID", "BeerID", fermenter.BeerID);
            return(View(fermenter));
        }
Beispiel #6
0
        private static async void initializeDB(BrewOSContext context)
        {
            if (!await context.Sensors.AnyAsync())
            {
                var item = new TemperatureSensor()
                {
                    Address = "ADR",
                    Name    = "NM"
                };
                context.Sensors.Add(item);
                await context.SaveChangesAsync();
            }

            if (!await context.Styles.AnyAsync())
            {
                var styleImages = Directory.GetFiles("./wwwroot/images/BeerImages/");



                TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

                foreach (var styleImage in styleImages)
                {
                    string style = textInfo.ToTitleCase(Path.GetFileNameWithoutExtension(styleImage).Replace('-', ' '));

                    var beerStyle = new BeerStyle();

                    beerStyle.StyleImage = styleImage.Replace("/wwwroot", "");
                    beerStyle.StyleName  = style;

                    context.Styles.Add(beerStyle);
                }

                await context.SaveChangesAsync();
            }
        }