Exemple #1
0
        public IActionResult Edit(int id, [Bind("Id,Name,Comment,Price,Available")] Beer beer)
        {
            if (id != beer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _repo.Update(beer);
                    _repo.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_repo.Exists(beer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(beer));
        }
        public bool Update(int id, BeerData beerData)
        {
            bool isUpdated = beerRepository.Update(id, new Demo_API_BeerAPI.DAL.Entities.BeerEntity()
            {
                Name      = beerData.Name,
                Color     = beerData.Color,
                Degree    = beerData.Degree,
                IdBrewery = beerData.IdBrewery,
                IdBrand   = beerData.IdBrand
            });

            return(isUpdated);
        }
Exemple #3
0
        public IHttpActionResult Update([FromBody] Beer beer)
        {
            if (Beer.IsValid(beer))
            {
                Beer updatedBeer = beerRepository.Update(beer);

                if (updatedBeer != null)
                {
                    return(Ok(updatedBeer));
                }
                else
                {
                    return(Content(HttpStatusCode.BadRequest, ""));
                }
            }
            else
            {
                return(Content(HttpStatusCode.BadRequest, ""));
            }
        }
 public Beer Update(Beer beer)
 {
     return(_BeerRepository.Update(beer));
 }