this code: “[HttpGet(”/user/tasks/{id:int}“)] public async Task tasks(int id) { var set = _context.Users.Where(x => x.Id == id).FirstOrDefault(); var maxi = await _context.MaximumTasks.Where(x => x.Id == 1).FirstOrDefaultAsync(); if (set == null || set.DailyDoneTasks == maxi.Value) { string reactPath = “/”; return Content(reactPath); } var loop = _context.CompletedTasks.Where(x => x.UserId == id).Select(x => x.TaskId).ToList(); var data = _context.Tasks.ToList(); var getins = new multi(); getins.users = set; getins.complete = _context.CompletedTasks.Where(x => x.UserId == id).ToList(); if (loop != null) { var show = data.Where(x => !loop.Contains(x.Id)).ToList(); getins.tasky = show; } getins.tasky = data; foreach (var item in getins.tasky) { var checker = await _context.CompletedTasks.ToListAsync(); var compare = await _context.StaticMsgs.ToListAsync(); if (item.Type == “text”) { if (item.RoundTxt1 == true) { if (checker == null) { var assigned = compare.FirstOrDefault(); var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = assigned?.Txt; getins.stattxt.Add(gg); } else { var checkagain = await _context.CompletedTasks.Where(x => x.TaskId == item.Id).OrderBy(x => x.Id).LastOrDefaultAsync(); if (checkagain?.StaticTxt == compare.OrderBy(x => x.Id).LastOrDefault()?.Txt) { item.RoundTxt1 = false; item.RoundTxt2 = true; Random random = new Random(); var randomItem = compare[random.Next(compare.Count)]; var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = randomItem?.Txt; getins.stattxt.Add(gg); } else { var current = checkagain != null ? _context.StaticMsgs.FirstOrDefault(x => x.Txt == checkagain.StaticTxt) : null; int currentIndex = compare.IndexOf(current); int nextIndex = currentIndex + 1; var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = compare[nextIndex]?.Txt; getins.stattxt.Add(gg); } } } else { Random random = new Random(); var randomItem = compare[random.Next(compare.Count)]; var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = randomItem?.Txt; getins.stattxt.Add(gg); } } else if (item.Type == “img”) { var tt = item.StaticImgs?.Split(”,“); if (item.RoundTxt1 == true) { if (checker == null) { var assigned = compare.FirstOrDefault(); var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = assigned?.Txt; getins.stattxt.Add(gg); } else { var checkagain = await _context.CompletedTasks.Where(x => x.TaskId == item.Id).OrderBy(x => x.Id).LastOrDefaultAsync(); if (checkagain?.StaticTxt == compare.OrderBy(x => x.Id).LastOrDefault()?.Txt) { item.RoundTxt1 = false; item.RoundTxt2 = true; Random random = new Random(); var randomItem = compare[random.Next(compare.Count)]; var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = randomItem?.Txt; getins.stattxt.Add(gg); } else { var current = checkagain != null ? _context.StaticMsgs.FirstOrDefault(x => x.Txt == checkagain.StaticTxt) : null; int currentIndex = compare.IndexOf(current); int nextIndex = currentIndex + 1; var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = compare[nextIndex]?.Txt; getins.stattxt.Add(gg); } } } else { Random random = new Random(); var randomItem = compare[random.Next(compare.Count)]; var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = randomItem?.Txt; getins.stattxt.Add(gg); } if (item.RoundImg1 == true) { if (checker == null) { var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = tt[0]; getins.statimg.Add(gg); } else { var checkagain = await _context.CompletedTasks.Where(x => x.TaskId == item.Id).OrderBy(x => x.Id).LastOrDefaultAsync(); if (checkagain?.StaticImg?.ToString() == tt?.Last()) { item.RoundImg1 = false; item.RoundImg2 = true; Random random = new Random(); string randomItem = tt[random.Next(tt.Length)]; var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = randomItem; getins.statimg.Add(gg); } else { var index = Array.IndexOf(tt.ToArray(), checkagain?.StaticImg); // Get the next item in line string nextItem = null; if (index >= 0 && index < tt.Length - 1) { nextItem = tt[index + 1]; } var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = nextItem; getins.statimg.Add(gg); } } } else { Random random = new Random(); string randomItem = tt[random.Next(tt.Length)]; var gg = new getTask(); gg.id = set.Id; gg.taskId = item.Id; gg.value = randomItem; getins.statimg.Add(gg); } } } return Ok(getins); }” keeps returning null errors, check the entire code and fix it.