public async Task <IActionResult> Edit(int id, [Bind("Id,Style")] BeerStyle beerStyle) { if (id != beerStyle.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(beerStyle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BeerStyleExists(beerStyle.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(beerStyle)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,BreweryId,Abv,StyleId,Notes")] BeerViewModel beer) { if (id != beer.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(beer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!_common.BeerExists(beer.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } beer.BreweryList = _common.GetBreweryChoices(); beer.StyleList = _common.GetStyleChoices(); return(View(beer)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,BeerId,Comment,Rating,UserId")] Ratings ratings) { if (id != ratings.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(ratings); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RatingsExists(ratings.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(ratings)); }
public async Task UpdateStock(UpdateBeerStockCommand command) { if (command.Stock <= 0) { throw new CustomBadRequestException("Stock should be positive"); } var wholesalerBeer = await _beerContext.WholesalerBeers .FindAsync(command.WholesalerId, command.BeerId); wholesalerBeer.Stock = command.Stock; _beerContext.Update(wholesalerBeer); await _beerContext.SaveChangesAsync(); }
public void Update(Beer beer) { _context.Update(beer); }