public async Task<IActionResult> UpdateUser(string routeName, int sourceLocation, int destinationLocation, int sequence, List<UpdateRouteDto> routeDto)
        {
            
            int max = await _dbContext.RouteDetails
            .Where(x => x.RouteSummary.RouteName == routeName && x.RouteSummary.SourceLocation == sourceLocation && x.RouteSummary.DestinationLocation == destinationLocation)
            .MaxAsync(x => x.Sequence);

            var routeId = await _dbContext.RouteSummaries
            .Where(x => x.RouteName == routeName && x.SourceLocation == sourceLocation && x.DestinationLocation == destinationLocation)
            .Select( x => x.RouteId)
            .FirstOrDefaultAsync();

            if(sequence == 0){
                    var deletedRoute = await _dbContext.RouteSummaries.FindAsync(routeId);
                    _dbContext.RouteSummaries.Remove(deletedRoute);
                    //await _dbContext.SaveChangesAsync();

                    return (IActionResult)deletedRoute;
                }

            string response;

            if(max > sequence){
                var deletedData = await _dbContext.RouteDetails
                .Where(x => x.RouteSummary.RouteName == routeName && x.RouteSummary.SourceLocation == sourceLocation && x.RouteSummary.DestinationLocation == destinationLocation)
                .OrderByDescending(x => x.Sequence)
                .Take(max-sequence)
                .ToListAsync();

                _dbContext.RouteDetails.RemoveRange(deletedData);
                await _dbContext.SaveChangesAsync();
                response = $"{max - sequence} Data deleted successfully";
            }
            else if(max < sequence){

                int insertData = sequence - max;

                var rowsToAdd = new List<RouteDetail>();

                for (int i = 1; i <= insertData; i++)
                {
                    var newRow = new RouteDetail
                    {
                        Sequence = max + i,
                        RouteSummaryId = routeId
                    };
                    rowsToAdd.Add(newRow);
                }

                _dbContext.RouteDetails.AddRange(rowsToAdd);
                await _dbContext.SaveChangesAsync();

                response = $"{sequence - max} Data added successfully";
            }

           var existingRows = await _dbContext.RouteDetails
            .Where(x => x.RouteSummary.RouteName == routeName && x.RouteSummary.SourceLocation == sourceLocation && x.RouteSummary.DestinationLocation == destinationLocation)
            .OrderBy(x => x.Sequence)
            .ToListAsync();

        for (int i = 0; i < existingRows.Count && i < routeDto.Count; i++)
        {
            existingRows[i].RouteLocation = routeDto[i].RouteLocation;
            existingRows[i].UserModify = routeDto[i].UserModify;
            existingRows[i].RouteSummaryId = routeId;
            if (!string.IsNullOrEmpty(routeDto[i].UserAdd))
            {
                existingRows[i].UserAdd = routeDto[i].UserAdd;
            }
        }

        await _dbContext.SaveChangesAsync();

        return Ok();
        }

I got this instead

at API.Controllers.routeController.UpdateUser(String routeName, Int32 sourceLocation, Int32 destinationLocation, Int32 sequence, List`1 routeDto) in C:\Users\AdityaYulfan\Documents\IFBT Projects\Itrack_V2\API\Controllers\RouteController.cs:line 132 at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>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.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>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 API.Middleware.ExceptionMiddleware.InvokeAsync(HttpContext context) in C:\Users\AdityaYulfan\Documents\IFBT Projects\Itrack_V2\API\Middleware\ExceptionMiddleware.cs:line 23