【发布时间】:2021-03-08 21:06:07
【问题描述】:
在我的医生表中,我有 3 列分别命名为开始时间、结束时间和持续时间。
我的计划是当用户输入城市名称并选择医生的专业并单击搜索按钮时,将显示符合该条件的医生表。包括开始时间、结束时间和时间段。
如果医生的开始时间为上午 8 点,结束时间为晚上 8 点,每位患者的平均持续时间为 30 分钟,则将创建 24 个时隙。
除了我不知道如何将所有内容与时间段下拉列表结合起来(当然不会显示特定日期已预订的时间)之外,我的大多数事情都在工作。
现在我已经在 var details 中有医生的详细信息(包括开始和结束时间),所以我应该能够从那里提取开始时间和结束时间吧?
并将这两条数据发送到 slot.cs 类以创建插槽?
这是我的操作方法:
public ActionResult Dashboard(string city, string specialization)
{
// ?City=Dhaka&specialization=Medicine&date=2020-11-29&btn_find=Find ---> example query string
string city_local = Request.Params["city"];
string specialization_local = Request.Params["specialization"];
var details = db.doctors
.Where(x => x.city.Equals(city_local) &&
x.specialization.Equals(specialization_local)).ToList(); -->this guy right here
return View(details);
}
这是我的看法:
<table class="table table table-borderless table-hover text-center">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Start Time</th>
<th>End Time</th>
<th>Available Slot</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@if(Model.Count() == 0)
{
<tr>
<td>No Records Found. Try Again</td>
</tr>
}
else
{
foreach(var data in Model)
{
<tr>
<td>@data.doctor_id</td>
<td>@data.doctor_fname</td>
<td>@data.start_time</td>
<td>@data.end_time</td>
<td>A dropdown of slots needed</td>
<td><a href="#">Book</a></td>
</tr>
}
}
</tbody>
</table>
最后是我的 slot.cs,它应该可以用于创建时隙:
public class slot
{
public TimeSpan StartTime { get; set; }
public TimeSpan Duration { get; set; }
public string DisplayString
{
get
{
return StartTime.ToString(@"hh\:mm") + " - " + (StartTime + Duration).ToString(@"hh\:mm");
}
}
public slot(TimeSpan StartTime, TimeSpan Duration)
{
this.StartTime = StartTime;
this.Duration = Duration;
}
public List<slot> TimeSlots(TimeSpan start, TimeSpan end, TimeSpan duration)
{
List<slot> slots = new List<slot>();
while (start < end)
{
slots.Add(new slot(start, duration));
start = start + duration;
}
return slots;
}
}
谁能帮忙解决这个问题?
【问题讨论】:
标签: c# asp.net asp.net-mvc-5