Ejemplo n.º 1
0
        public void Update(RestaurantFoodDTO modelDTO, IFormFile file)
        {
            var model = _mapper.Map <RestaurantFood>(modelDTO);

            Errors.ThrowIfNull(model);

            if (file != null)
            {
                model.PathToImage = UpdateFile(file);
            }

            _db.Update(model);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Put(
            [FromForm][ModelBinder(BinderType = typeof(FormDataJsonBinder))]
            RestaurantFoodDTO model,
            [FromForm] IFormFile file)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            _foodService.Update(model, file);

            await _foodService.SaveDataBase();

            return(Ok());
        }