Exemple #1
0
        //Updates a drink-object with same parameters but different values.
        public async Task <DrinkForUpdateDto> Update(int id, DrinkForUpdateDto dr)
        {
            var dbDrink = await _context.Drinks
                          .FirstOrDefaultAsync(e => e.Id == id);

            dbDrink.ProductNameBold = dr.ProductNameBold;
            dbDrink.Price           = dr.Price;
            dbDrink.Volume          = dr.Volume;
            dbDrink.Category        = dr.Category;
            dbDrink.Taste           = dr.Taste;
            dbDrink.Image           = dr.Image;

            await _context.SaveChangesAsync();

            return(DrinkTranslator.ToDrinkForUpdateDto(dbDrink));
        }
Exemple #2
0
        public async Task <IActionResult> UpdateDrink(int id, [FromBody] DrinkForUpdateDto dr)
        {
            var result = await _drinkService.Update(id, dr);

            return(new OkObjectResult(ApiResponse.Create(result)));
        }