public async Task <IActionResult> Edit([FromRoute] int id, [FromBody] EditRestaurantRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var response = await _restaurantService.EditAsync(id, request); if (!response.IsValid) { return(BadRequest(response.Message)); } return(Ok(response)); }
public async Task <BaseResponse> EditAsync(int id, EditRestaurantRequest request) { var restaurant = await _restaurantRepository.GetByIdAsync(id); if (restaurant == null) { return(new BaseResponse("Restaurant is not found")); } restaurant.Title = request.Title; restaurant.Description = request.Description; _restaurantRepository.Update(restaurant); await _unitOfWork.SaveChangesAsync(); return(new BaseResponse()); }