public async Task <IActionResult> Create([Bind("Id,Style")] BeerStyle beerStyle) { if (ModelState.IsValid) { _context.Add(beerStyle); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(beerStyle)); }
public async Task <IActionResult> Create([Bind("Name,BreweryId,Abv,StyleId,Notes")] BeerViewModel beer) { if (ModelState.IsValid) { _context.Add(beer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } beer.BreweryList = _common.GetBreweryChoices(); beer.StyleList = _common.GetStyleChoices(); return(View(beer)); }
public async Task <IActionResult> Create([Bind("BreweryName,Location")] Brewery brewery) { if (!_common.BreweryExists(brewery.Id)) { if (ModelState.IsValid) { _context.Add(brewery); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(View(brewery)); }
public async Task <IActionResult> Create([Bind("BeerId,Comment,Rating,UserId")] RatingViewModel ratings) { var _user = await _userManager.GetUserAsync(HttpContext.User); if (ModelState.IsValid) { ratings.UserId = _context.User.Where(x => x.Email == _user.Email).Select(x => x.Id).FirstOrDefault(); var rating = _common.GetRatingFromViewModel(ratings); _context.Add(rating); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(ratings)); }