i have a project i'm doing in C# ASP.Net MVC5 as my backend,and my frontend is also in C#.how will i bind the two for them to communicate.i'm using a search engine in my frontend to get data from the backend and SQL server.i need your good answers.
I have 3 tables,Students,Courses and Student_courses.my backend works well,i am confused on how to use the frontend to run queries to get results.i can't use the same method i used on the backend for the frontend.i don't need api again.query to get results i need
What I have tried:
this is my search view for the front end
@model UniScore.ViewModels.StudentCoursesViewModel
@{
Layout = "~/Views/Shared/_Layout2.cshtml";
}
<h1 align="center">SEARCH STUDENT</h1>
<br />
<div class="container">
@using (Html.BeginForm("Search", "Search", FormMethod.Get))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<p>Please type in your Student ID and First Name</p>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.FirstName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.FirstName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.FirstName, "", new { @class = "text-danger" })
</div>
</div>
<br />
<div class="form-group">
@Html.LabelFor(model => model.id_Student, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.id_Student, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.id_Student, "", new { @class = "text-danger" })
</div>
</div>
<br />
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="SearchResults" class="btn btn-default" />
</div>
</div>
</div>
}
</div>
Student table has(id_student,firstname and lastname),
Course table has(id_course,code,course name)
Student_course table(id,student_id,course_id,mark,grade)...now every student can do a lot of courses.i didn't use foreign keys.
How can i use the view to display the courses a student is undertaking in the search,which linq query will i use to display values in the controller.if you can give me idea of how to code in the controller i will be fine.