コード例 #1
0
        public async Task <IActionResult> PutRestaurant(Guid id, V1DTO.Restaurant restaurant)
        {
            if (id != restaurant.Id)
            {
                return(BadRequest(new V1DTO.MessageDTO("Id and Restaurant.Id do not match")));
            }

            await _bll.Restaurants.UpdateAsync(_mapper.Map(restaurant));

            await _bll.SaveChangesAsync();

            return(NoContent());
        }
コード例 #2
0
        public async Task <ActionResult <V1DTO.Restaurant> > PostRestaurant(V1DTO.Restaurant restaurant)
        {
            var bllEntity = _mapper.Map(restaurant);

            _bll.Restaurants.Add(bllEntity);
            await _bll.SaveChangesAsync();

            restaurant.Id = bllEntity.Id;

            return(CreatedAtAction("GetRestaurant",
                                   new { id = restaurant.Id, version = HttpContext.GetRequestedApiVersion()?.ToString() ?? "0" },
                                   restaurant));
        }