Binding checkbox to model and not return checked states in ASP.NET MVC

When binding checkboxes in a form to a list of models is it possible to return the List<Model> instead of merely the string[] of IDs of the checked boxes?

Ideally I would like to receive the List<Result> after form submission to simply update the previously created entries. Is this a feasible option?

Controller:

public IActionResult Quiz()
{
    //var test = _context2.Questions.Include(test => test.MultipleChoices);;
    //var allQuestions = _context2.Questions.Include(allQuestions => allQuestions.MultipleChoices).ToList();

    var allQuestions = _context2.Questions.Include(allQuestions => allQuestions.Answers).ThenInclude(answers => answers.MultipleChoices).ToList();
    List<Result> allResults = new List<Result>();

    _context2.Results.ExecuteDelete();

    foreach (Question question in allQuestions)
    {
        foreach (Answer answer in question.Answers)
        {
            if (answer.AnswerType.Equals("MultipleChoice"))
            {
                foreach (MultipleChoice multipleChoiceToAdd in answer.MultipleChoices)
                {
                    _context2.Results.Add(createResultToAdd(question, answer));
                    allResults.Add(createResultToAdd(question, answer));
                }
            }
            else if (answer.AnswerType.Equals("TextAnswer"))
            {
                _context2.Results.Add(createResultToAdd(question, answer));
                allResults.Add(createResultToAdd(question, answer));
            }
        }
    }

    _context2.SaveChanges();

    allResults = _context2.Results
                          .Include(allResults2 => allResults2.Question)
                          .Include(allResults2 => allResults2.Answer)
                          .ThenInclude(answer => answer.MultipleChoices)
                          .Include(allResults2 => allResults2.Answer)
                          .ThenInclude(answer => answer.TextAnswers).ToList();

    return View(allResults);
}

private Result createResultToAdd(Question question, Answer answerTemplate)
{
    Result resultToAdd = new Result();
    resultToAdd.QuestionId = question.QuestionId;
    resultToAdd.AnswerId = answerTemplate.AnswerId;
    resultToAdd.CheckedResult = true;

    return resultToAdd;
}

[HttpPost]
public IActionResult StoreResult(string[] result) //List<Result> results
{
    System.Diagnostics.Debug.WriteLine(result);

    return RedirectToAction("Index");
}

View:

@{
    ViewData["Title"] = "Quiz";
}
@model List<Result>
<div class="text-center">
    <h1 class="display-4">Quiz</h1>
    <form asp-controller="Home" asp-action="StoreResult" method="post">
        @{
            foreach (var QuestionID in Model.OrderBy(m => m.QuestionId).GroupBy(m => m.QuestionId))
            {
                
                var question = @Model.Where(m => m.QuestionId == QuestionID.Key).Select(m => m.Question).First();

                <div class="container-fluid" style="background: #d7f6c8 ;">
                    @{
                        <h2>@question.QuestionText</h2>
                        if (question.ImageAttachment != null)
                        {
                            <img [email protected] style="width:5em;" alt="Sample Photo" />
                        }

                        var checkBoxIndices = @Model.Where(m => m.QuestionId == QuestionID.Key).Select(m => Model.IndexOf(m)).ToList();
                        var result2 = Model.Where(m => m.QuestionId == QuestionID.Key).ToList();


                        <table class="table">
                            <tbody>
                                @{
                                    if (question.QuestionType.Equals("MultipleChoice"))
                                    {
                                        //foreach (var answer in Model.Where(m => m.QuestionId == QuestionID.Key).ToList())
                                        foreach (int modelAnswerIndex in checkBoxIndices)
                                        {
                                            
                                            if (Model[modelAnswerIndex].Answer.AnswerType.Equals("MultipleChoice"))
                                            {
                                                var mcqAnswer = Model[modelAnswerIndex].Answer.MultipleChoices.FirstOrDefault();
                                                if (Model[modelAnswerIndex].Question.SingleSelect)
                                                {
                                                <td>
                                                        @if (Model[modelAnswerIndex].Answer.MultipleChoices.First().ImageAttachment == null)
                                                        {
                                                            @Model[modelAnswerIndex].Answer.AnswerText  @*Option Text *@
                                                        }
                                                        else
                                                        {
                                                            @Model[modelAnswerIndex].Answer.AnswerText  @*Option Text *@
                                                        <img [email protected] style="width:5em;" alt="Sample Photo" />
                                                        }
                                                    <input class="form-check-input" type="radio" name="Result" value="@Model[modelAnswerIndex].ResultId" checked="@Model[modelAnswerIndex].CheckedResult"> @*Radio Button *@
                                                </td>
                                                }
                                                else
                                                {
                                                <td>
                                                        @if (mcqAnswer.ImageAttachment == null)
                                                        {
                                                            @Model[modelAnswerIndex].Answer.AnswerText  @*Option Text *@
                                                        }
                                                        else
                                                        {
                                                                @Model[modelAnswerIndex].Answer.AnswerText  @*Option Text *@
                                                        <img [email protected] style="width:5em;" alt="Sample Photo" />
                                                        }


                                                    <input class="form-check-input" type="checkbox" name="Result" value="@Model[modelAnswerIndex].ResultId" checked="@Model[modelAnswerIndex].CheckedResult">
                                                </td>
                                                }
                                                // }
                                            }
                                        }
                                    }
                                }
                            </tbody>
                        </table>
                    }
                </div>
            }
        }
        <button class="btn btn-primary mt-4"  type="submit">Abgabe</button>
    </form>
</div>

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật