ita-social-projects / ita-social-projects/StreetCode_Client

[Streetcode Delete] Deletion is broken on Streetcode Admin page.

Open
#399 0 comments 0 reactions 1 assignee Claimed by @MariaPadalka View on GitHub
bug
Dominant language
TypeScript
Stars
15
Forks
10
PR merge metrics
No merged PRs in 30d

Description

**Environment:** All browsers.
**Reproducible:** always.
**Build found:** commit https://github.com/ita-social-projects/StreetCode_Client/commit/76687e96efa660445ddd703d9499dbe2f7179011

**Preconditions**
You should have at least one streetcode seeded in the database.

**Steps to reproduce**
1. Go to [Admin page](http://localhost:3000/admin-panel)
2. Click on Trash bin in the table row.
![image](https://github.com/ita-social-projects/StreetCode_Client/assets/77460353/18f8c4e9-5bc9-4567-b88e-6dac10e35a27)
3. Click Ok in modal window.

**Actual result**
Error code showing in console, listed below.

fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMRHBTKC4I9N", Request id "0HMRHBTKC4I9N:000002A7": An unhandled exception was thrown by the application.
System.InvalidOperationException: The association between entity types 'StreetcodeContent' and 'RelatedFigure' has been severed, but the relationship is either marked as required or is implicitly required because the foreign key is not nullable. If the dependent/child entity should be deleted when a required relationship is severed, configure the relationship to use cascade deletes. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the key values.
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.HandleConceptualNulls(Boolean sensitiveLoggingEnabled, Boolean force, Boolean isCascadeDelete)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.CascadeDelete(InternalEntityEntry entry, Boolean force, IEnumerable`1 foreignKeys)
at Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry.set_State(EntityState value)
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.Remove(TEntity entity)
at Streetcode.DAL.Repositories.Realizations.Base.RepositoryBase`1.Delete(T entity) in D:\savings\SoftServe\streetcode\StreetCode\Streetcode\Streetcode.DAL\Repositories\Realizations\Base\RepositoryBase.cs:line 48
at Streetcode.BLL.MediatR.Streetcode.Streetcode.Delete.DeleteStreetcodeHandler.Handle(DeleteStreetcodeCommand request, CancellationToken cancellationToken) in D:\savings\SoftServe\streetcode\StreetCode\Streetcode\Streetcode.BLL\MediatR\Streetcode\Streetcode\Delete\DeleteStreetcodeHandler.cs:line 30
at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)
at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)
at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)
at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)
at Streetcode.WebApi.Controllers.Streetcode.StreetcodeController.Delete(Int32 id) in D:\savings\SoftServe\streetcode\StreetCode\Streetcode\Streetcode.WebApi\Controllers\Streetcode\StreetcodeController.cs:line 130
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Watch.BrowserRefresh.BrowserRefreshMiddleware.InvokeAsync(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

**Expected result**
Deleting the Streetcode safely without errors and removing it from the database.

**Postconditions**
No specific postconditions.

**User story and test case links**
Epic [#144](https://github.com/ita-social-projects/StreetCode/issues/114)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.