예제 #1
0
        public Task <HttpResponseMessage> Update([FromBody] dynamic body)
        {
            var command = new UpdatePlateCommand(
                plateId: (int)body.plateId,
                plateName: (string)body.plateName,
                price: (decimal)body.price,
                restaurantId: (int)body.restaurantId
                );

            var plate = _service.Update(command);

            return(CreateResponse(HttpStatusCode.Created, plate));
        }
예제 #2
0
        public Plate Update(UpdatePlateCommand command)
        {
            var plate = _repository.GetById(command.PlateId, command.RestaurantId);

            if (plate == null)
            {
                return(null);
            }

            plate.Update(command.PlateName, command.Price, command.RestaurantId);
            _repository.Update(plate);

            if (Commit())
            {
                return(plate);
            }

            return(null);
        }