예제 #1
0
        public Task <HttpResponseMessage> Create([FromBody] dynamic body)
        {
            var command = new CreateRestaurantCommand(
                restaurantName: (string)body.restaurantName
                );

            var restaurant = _service.Create(command);

            return(CreateResponse(HttpStatusCode.Created, restaurant));
        }
        public _Restaurant Create(CreateRestaurantCommand command)
        {
            var restaurant = new _Restaurant(command.RestaurantName);

            restaurant.Create();
            _repository.Create(restaurant);

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

            return(null);
        }
예제 #3
0
        public async Task <IActionResult> CreateRestaurant(
            [FromBody] CreateRestaurantRequestModel createRestaurantRequestModel)
        {
            var claimsIdentity = User.Identity as ClaimsIdentity;
            var command        = new CreateRestaurantCommand(createRestaurantRequestModel.Name,
                                                             createRestaurantRequestModel.Address, createRestaurantRequestModel.PhoneNumber,
                                                             createRestaurantRequestModel.FaxNumber,
                                                             createRestaurantRequestModel.Email, createRestaurantRequestModel.Website,
                                                             claimsIdentity?.FindFirst(ClaimTypes.NameIdentifier)?.Value, createRestaurantRequestModel.TableCount,
                                                             createRestaurantRequestModel.Link);
            var response = await _mediator.Send(command);

            return(response.ToActionResult());
        }
예제 #4
0
        public async Task <ActionResult <RestaurantsListVm> > Create([FromBody] CreateRestaurantCommand command)
        {
            var vm = await Mediator.Send(command);

            return(Ok(vm));
        }