Exemplo n.º 1
0
        public async Task <IActionResult> UpdateShoppingList(long listId, ShoppingList listToUpdate)
        {
            if (listToUpdate == null)
            {
                return(BadRequest("You must provide a ShoppingList to update"));
            }

            if (listId == listToUpdate.ShoppingList_Id)
            {
                return(BadRequest("A matching list ID must be provided"));
            }

            ShoppingListDTO checkList = await shoppingListRepository.GetShoppingListByIdAsync(listId);

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

            await shoppingListRepository.UpdateShoppingListAsync(dtoMapper.Map <ShoppingListDTO>(listToUpdate));

            return(Ok());
        }
        public void UpdateShoppingListAsync_NullParameterThrows()
        {
            repository = new ShoppingListRepository(context);

            Assert.ThrowsAsync <ArgumentNullException>(() => repository.UpdateShoppingListAsync(null));
        }