Beispiel #1
0
 public IActionResult Put([FromBody] RestaurantInputModel inputModel)
 {
     try
     {
         return(ResponseOk(_restaurantAppService.Update(inputModel)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Beispiel #2
0
        public Task <HttpResponseMessage> Update([FromBody] dynamic body)
        {
            var command = new UpdateRestaurantCommand(
                restaurantId: (int)body.restaurantId,
                restaurantName: (string)body.restaurantName
                );

            var restaurant = _service.Update(command);

            return(CreateResponse(HttpStatusCode.Created, restaurant));
        }
Beispiel #3
0
 public ActionResult <RestaurantViewModel> Put(Guid id, [FromBody] RestaurantViewModel value)
 {
     if (id != value.Id)
     {
         return(BadRequest());
     }
     else
     {
         return(_restaurantAppService.Update(value));
     }
 }
Beispiel #4
0
        public IActionResult Put([FromBody] RestaurantViewModel restaurantViewModel)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(restaurantViewModel));
            }

            _restaurantAppService.Update(restaurantViewModel);

            return(Response(restaurantViewModel));
        }
        public ActionResult Edit(RestaurantEditViewModel model)
        {
            var result = new ResultApi <RestaurantListViewModel>();

            try
            {
                var restaurant = _restaurantAppService.GetById(model.RestaurantId);
                restaurant.ChangeName(model.Name);
                _restaurantAppService.Update(restaurant);
            }
            catch (Exception e)
            {
                result.Sucesso  = false;
                result.Mensagem = e.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }