예제 #1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = FunctionConstants.TodoList.Delete + "/{id}")]
            HttpRequest req, string id)
        {
            var user = _authService.GetClientPrincipalFromRequest(req);

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

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


            if (_todoListService.DeleteByRowKey(id))
            {
                _itemService.DeleteEntitiesWithPartitionKey(id);
                return(new NoContentResult());
            }

            return(new NotFoundResult());
        }