コード例 #1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = FunctionConstants.TodoItem.Delete + "/{listId}/{itemId}")]
            HttpRequest req,
            string listId,
            string itemId)
        {
            var user = _authService.GetClientPrincipalFromRequest(req);

            if (!_todoListService.CanUserAccessList(user, listId, ShareRole.Edit))
            {
                return(new UnauthorizedResult());
            }

            if (string.IsNullOrEmpty(itemId))
            {
                return(new BadRequestObjectResult("Id or listId cannot be empty"));
            }


            if (!await _itemService.DeleteAsync(listId, itemId))
            {
                return(new NotFoundResult());
            }

            return(new NoContentResult());
        }
コード例 #2
0
        protected override async Task <object> ExecuteFlowStepsAsync(DeleteTodoItemInfo input, IPrincipal flowInitiator)
        {
            input.Owner = flowInitiator;
            await todoItemService.DeleteAsync(input);

            return(null);
        }
コード例 #3
0
        public async Task <IActionResult> DeleteAsync(int id)
        {
            var result = await _todoItemService.DeleteAsync(id);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            return(Ok(result.TodoItem));
        }
        public async Task <ActionResult <TodoItemDTO> > DeleteAsync(int id)
        {
            try
            {
                await _service.DeleteAsync(id);

                return(NoContent());
            }
            catch (NullReferenceException e)
            {
                return(NotFound(e));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }
コード例 #5
0
ファイル: ToDoItemController.cs プロジェクト: SZ559/ToDoItems
        public async Task <ActionResult> DeleteAsync([Required] string id)
        {
            /// <response code="400">If id is empty</response>
            //if (string.IsNullOrEmpty(id))
            //    return BadRequest(new Dictionary<string, string>() { { "message", "Id is required" } });
            var itemToBeDeleted = await _service.GetAsync(id);

            if (itemToBeDeleted == null)
            {
                return(NotFound(new Dictionary <string, string>()
                {
                    { "message", $"Can't find {id}" }
                }));
            }

            await _service.DeleteAsync(id);

            return(StatusCode(204));
        }
コード例 #6
0
        public async Task <ActionResult> Delete(int id)
        {
            await _todoItemService.DeleteAsync(id);

            return(Ok());
        }
コード例 #7
0
 public async Task <IActionResult> DeleteAsync(Guid id)
 {
     return(Ok(ApiResult <BaseResponseModel> .Success(await _todoItemService.DeleteAsync(id))));
 }