示例#1
0
        public async Task <ActionResult <Data.Models.GroceryList> > PostGroceryList(Data.Models.GroceryList groceryList)
        {
            if (groceryList == null)
            {
                return(BadRequest());
            }

            await _groceryListService.Create(groceryList);

            return(CreatedAtAction("GetGroceryList", new { id = groceryList.Id }, groceryList));
        }
示例#2
0
        public async Task <IActionResult> PutGroceryList(int id, Data.Models.GroceryList groceryList)
        {
            if (id != groceryList.Id || groceryList == null)
            {
                return(BadRequest());
            }

            var _groceryListExists = await _groceryListService.GetById(id);

            if (_groceryListExists == null)
            {
                return(NotFound());
            }

            await _groceryListService.Edit(groceryList);

            return(NoContent());
        }