i'm currently working on asp.net-mvc project for which i need to display available time in dropdownlist for the date that has been selected to the user. i'm using full calendar to display the date. Available time is store in the database. This is my view
@Html.LabelFor(model => model.date, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.date, new { htmlAttributes = new { @class = "form-control", id = "datepicker" } })
@Html.ValidationMessageFor(model => model.date, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.time, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.DropDownList("time", null, "--Select Time--", htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.time, "", new { @class = "text-danger" })
this is my controller
public ActionResult CreateBooking()
{
return View();
}
[HttpPost]
public ActionResult CreateBooking(bookingPatient bo)
{
try
{
b.booking(bo);
System.Web.HttpContext.Current.Session["date"] = bo.date;
return RedirectToAction("Index", "Booking");
}
catch
{
return View();
}
}
this is my business class
public void booking(bookingPatient model)
{
using (var bookpro = new BookingRepository())
{
if (model.BookingId == 0)
{
Booking _booking = new Booking
{
Date = model.date,
Time = model.time
};
bookpro.Insert(_booking);
System.Web.HttpContext.Current.Session["bookingId"] = _booking.BookingId;
}
}
}
this is my modelview
public class bookingPatient
{
public int id { get; set; }
public DateTime date{ get; set; }
public DateTime time { get; set; }
}
Someone please guide me in this regard. Thanks in advance