Пример #1
0
        public async Task <RestaurantDto> AddRestaurant(CreateRestaurantDto input)//add restaurant
        {
            var restaurant = Restaurant.Create(input.Name, input.Address);
            var result     = await _repository.AddAsync(restaurant);

            return(_mapper.Map <Restaurant, RestaurantDto>(result));
        }
Пример #2
0
        public ActionResult CreateRestaurant([FromBody] CreateRestaurantDto dto)
        {
            var userId = int.Parse(User.FindFirst(c => c.Type == ClaimTypes.NameIdentifier).Value);
            var id     = _restaurantService.Create(dto);

            return(Created($"/api/restaurant/{id}", null));
        }
Пример #3
0
        public int Create(CreateRestaurantDto dto)
        {
            var restaurant = _mapper.Map <Restaurant>(dto);

            _dbContext.Restaurants.Add(restaurant);
            _dbContext.SaveChanges();
            return(restaurant.Id);
        }
Пример #4
0
        public int Create(CreateRestaurantDto dto)
        {
            var restaurant = _mapper.Map <Restaurant>(dto);

            restaurant.CreatedById = _userContextService.GetUserId;
            _dbContext.Restaurants.Add(restaurant);
            _dbContext.SaveChanges();

            return(restaurant.Id);
        }
        public ActionResult CreateRestaurant([FromBody] CreateRestaurantDto dto)
        {
            int restaurantId = _restaurantService.Create(dto);

            return(Created($"/api/restaurant/{restaurantId}", null));
        }
Пример #6
0
        public ActionResult CreateRestaurant([FromBody] CreateRestaurantDto dto)
        {
            var id = _restaurantService.Create(dto);

            return(Created($"api/restaurant/{id}", null));
        }