I want to save information of TV programs faults. Each TV program has a number of different platforms. First user select the TV program then on the view I have a for each loop that shows the platforms that the specific TV program is available on.
I want to select in which platform we had video loss and select the quality of sound also.
I have defined disconnect object in the model that is the master table and the detail table is “disconnetdetails” that save the platforms that failure happened.
I want to create this list of details (disconnetdetails) in my view and pass it to controller.
In the view model :
public Disconnect Disconnect { get; set; }
// that shows the platforms available for selected TV program
public List<Models.ProgramPlatform> objProgramList { get; set; }
public List<Models.DisconnectDetails> objDisconnectDetails { get; set; }
// for choosing quality of sound
public IEnumerable<SelectListItem> Soundlist { get; set; }
// for choosing quality of video
public IEnumerable<SelectListItem> Videolist { get; set; }
In the view, I have:
// shows available platforms
@foreach (var obj in Model.objProgramList)
{
DisconnectDetails o = new DisconnectDetails();
<tr>
<td>
@obj.Platform.Name
<input type="number" asp-for="@o.PlatformId " asp-items=" @obj.PlatformId" hidden />
</td>
<td>
<select asp-for="@o.Sound" asp-items="@Model.Soundlist" class="form-select">
<option disabled selected>-- --</option>
</select>
</td>
<td>
<select asp-for="@o.video" asp-items=" @Model.Videolist" class="form-select">
<option disabled selected>-- --</option>
</select>
</tr>
@Model.objDisconnectDetails.AddRange(o);
}
In my controller, I have this code:
foreach (var o in obj.objDisconnectDetails)
{
_db.DisconnectDetails.Add(o);
}
_db.SaveChanges();
I want to add DisconnectDetails
to my list(objDisconnectDetails)
in the view and send it to the controller to save to the database.
nadjmeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
6