Exemplo n.º 1
0
        public async Task <IHttpActionResult> Post(int dishId, ItemModel[] itemsModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var items = _mapper.Map <Item[]>(itemsModel);

                    _repo.AddItemsToADish(items, dishId);

                    if (await _repo.SaveChangesAsync())
                    {
                        return(Created("GetItems", dishId));
                    }
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
            return(BadRequest());
        }