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));
        }
示例#2
0
 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));
     }
 }
示例#3
0
 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;
     }
 }
示例#4
0
 public UpdateFoodRequest1(UpdateFoodRequest updateFoodRequest) => UpdateFoodRequest = updateFoodRequest;
示例#5
0
 public async Task <UpdateFoodResult> UpdateFood(UpdateFoodRequest request)
 {
     return(await orderRepository.UpdateFood(request));
 }
示例#6
0
 public async Task <OkObjectResult> Update(UpdateFoodRequest request)
 {
     return(Ok(await foodService.UpdateFood(request)));
 }