Esempio n. 1
0
        public async Task <IActionResult> AddNewShoppingList([FromForm] string shoppingListName)
        {
            shoppingListName = shoppingListName.Trim();

            IApiResponse response;

            if (string.IsNullOrEmpty(shoppingListName))
            {
                response = new ApiResponse(HttpStatusCode.BadRequest)
                {
                    Message = "The shopping list must have a name."
                };

                return(new ObjectResult(response));
            }

            response = await _service.AddAsync(shoppingListName);

            return(new ObjectResult(response));
        }
Esempio n. 2
0
        public async Task <ActionResult <Item> > Post([FromBody] Item item)
        {
            await _service.AddAsync(item);

            return(CreatedAtAction(nameof(Get), item));
        }