Controller: public async Task AddSheduleWithEmp(int DepartmentId, DateTime Start, DateTime End) { //set test data. DepartmentId = 1; Start = DateTime.Now; End = DateTime.Now.AddDays(3); //List dates = Enumerable.Range(0, 1 + End.Subtract(Start).Days) // .Select(i => Start.AddDays(i).ToString("dd-MM-yyyy")) // .ToList(); //use this list to populate the date, and use it to transfer the data from view to the controller. List items = Enumerable.Range(0, 1 + End.Subtract(Start).Days) .Select(i => new EmpShiftSelected() { Date = Start.AddDays(i).ToString("dd-MM-yyyy") }) .ToList(); if (DepartmentId != 0) { //query database to populate the Dropdownlist. var Shifts = _dataRepository.Shifts().ToList(); var model = _dataRepository.Employees().Where(x => x.DepartmentId == DepartmentId).ToList(); //create a view model to populate the form. EmpShifts EmpShiftsView = new EmpShifts { DepartmentID = DepartmentId, Employees = model, Shifts = Shifts, //Dates = dates EmpShiftSelected = items, }; return View(EmpShiftsView); } return View(); } [HttpPost] public async Task AddSheduleWithEmp(EmpShifts model) { if (ModelState.IsValid) { var data = model; } return View(); } View : @model WebApplication1.Models.EmpShifts @{ ViewData["Title"] = "AddSheduleWithEmp"; }

AddSheduleWithEmp

@if (Model.EmpShiftSelected != null) { @for (int i = 0; i < Model.EmpShiftSelected.Count; i++) { }
Date Emplyoee Shift Priorety
@Model.EmpShiftSelected[i].Date
}
Back to List
@section Scripts { @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} }