public FoodResponse UpdateFood(UpdateFoodRequest request) { if (request == null) { AddNotification("UpdateFoodRequest", "Requisição inválida"); return(null); } Food food = _repositoryFood.ObterPorId(request.Id); if (food == null) { AddNotification("Id", "Dados não encontrados"); return(null); } food.Update(food.Name, food.Description, food.Price, food.ImageName, food.Category); AddNotifications(food); if (IsInvalid()) { return(null); } return((FoodResponse)_repositoryFood.Editar(food)); }
public async Task <HttpResponseMessage> Update(UpdateFoodRequest request) { try { var response = _serviceFood.UpdateFood(request); return(await ResponseAsync(response, _serviceFood)); } catch (Exception ex) { return(await ResponseExceptionAsync(ex)); } }
public async Task <UpdateFoodResult> UpdateFood(UpdateFoodRequest request) { try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@FoodId", request.FoodId); parameters.Add("@ShortContent", request.ShortContent); parameters.Add("@Description", request.Description); parameters.Add("@Address ", request.Address); parameters.Add("@Image ", request.Image); parameters.Add("@Price", request.Price); return(await SqlMapper.QueryFirstOrDefaultAsync <UpdateFoodResult>(cnn : connect, sql : "sp_UpdateFood", param : parameters, commandType : CommandType.StoredProcedure)); } catch (Exception) { throw; } }
public UpdateFoodRequest1(UpdateFoodRequest updateFoodRequest) => UpdateFoodRequest = updateFoodRequest;
public async Task <UpdateFoodResult> UpdateFood(UpdateFoodRequest request) { return(await orderRepository.UpdateFood(request)); }
public async Task <OkObjectResult> Update(UpdateFoodRequest request) { return(Ok(await foodService.UpdateFood(request))); }