int? ステータス パラメータが null ではなく、有効です。列挙型フィルターが尊重されない理由を知っている人はいますか? 読んでくれてありがとう!
public ActionResult GetArrivals(int facilityId, int? status)
{
var registrationList = db.Registrations
.Where(f => f.Facility.Id == facilityId)
.Where(a => a.ArrivalDateTime >= DateTime.Today)
.OrderBy(ln => ln.User.LastName)
.OrderBy(fn => fn.User.FirstName);
if (status.HasValue)
{
UrgentCareWaitWeb.Models.RegistrationStatus statusValue;
if (Enum.TryParse(status.Value.ToString(), out statusValue) == true)
{
registrationList
.Where(s => s.Status == statusValue);
}
}
// Project query to view
var pview = registrationList.Select(r => new PatientRegistrationsView()
{
ArrivalId = r.Id,
UserId = r.User.UserId,
UserName = r.User.UserName,
FirstName = r.User.FirstName,
LastName = r.User.LastName,
PrimaryPhone = r.User.PrimaryPhone,
SecondaryPhone = r.User.SecondaryPhone,
ArrivalDateTime = r.ArrivalDateTime,
PatientDataformId = r.PatientDataformId,
RegistrationStatus = r.Status,
});
//if (Request.IsAjaxRequest())
// return PartialView("_PatientRegistrations", model);
return View(pview);
}