Пример #1
0
        public async Task <IActionResult> DeleteConfirmed(Guid id, string filePath = "")
        {
            if (id == Guid.Empty)
            {
                return(NotFound());
            }

            var currentUser = await _userManager.GetUserAsync(User);

            bool successful;

            successful = await _todoItemService
                         .DeleteTodoAsync(id, currentUser);

            if (!successful)
            {
                return(BadRequest(new { error = "Couldn't delete item!" }));
            }

            try
            {
                successful = await _fileStorageService.DeleteFileAsync(filePath, id.ToString());

                if (!successful)
                {
                    return(BadRequest(new { error = "Couldn't delete item!" }));
                }
            }
            catch (ArgumentNullException) { }
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async Task <ActionResult> DeleteItem(Guid id)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                _logger.LogError($"Unknown user tried creating an item.");
                return(Unauthorized());
            }

            await _todoService.DeleteTodoAsync(id, user);

            _logger.LogInformation($"Removed item with id {id}.");
            return(NoContent());
        }