I have a problem in my application manager of Courses in ASP.NET MVC.
The scenario is as follows: I have a screen where the "Student" enrolls in a course. By clicking the "enroll" button, it is associated with a course and the number of vacancies of this course will be decremented. The screen Razor looks something like this:
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Nome_Curso)
</td>
<td>
@Html.DisplayFor(modelItem => item.Sigla)
</td>
...
<td>
<div class="btn-group">
<div class="col-md-offset-2 col-md-10">
<a href="@Url.Action("Inscricao", "Curso")">
<input type="submit" value="Inscrição" name="inscricao" class="inscricao btn btn-success" data-toggle ="modal", data-target="#modalaviso" data-inscricaoid="@item.CursoId" /></a>
</div>
</div>
</td>
</tr>
}
In this case, it only works if I pass the Id as a parameter in the URL. Example: My subscription URL is Courses / Inscription , so the button does nothing . Now if I pass the Id parameter it works like so: Courses / Inscription / 1 .
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script>
$(document).ready(function() {
$(".inscricao").click(function() {
$.ajax({
type: "POST",
url: "~/Curso/Inscricao/" + $(this).data("inscricaoid"),
success: function() {
$(this).attr("disabled", "disabled");
}
});
});
});
</script>
}
I do not want to be passing the Id in the URL. I need that when the "student" click on the "enrollment" button it will be associated with the course and the decremented vacancies without passing the Id in the URL.