My Model:
public partial class WorkTime
{
public int WorkTimeId { get; set; }
public int CalendarId { get; set; }
public string DayName { get; set; }
public System.DateTime FromTime { get; set; }
public System.DateTime ToTime { get; set; }
public int DurationBreak { get; set; }
public bool IsEnabled { get; set; }
public virtual Calendar Calendar { get; set; }
}
Index.cshtml:
var start = $("#FromTime").kendoTimePicker({
change: startChange,
type: "string",
format: "HH:mm tt",
parseFormats: ["HH:mm"],
value:kendo.stringify(this.value),
});
var end = $("#ToTime").kendoTimePicker({
type: 'string',
format: "datetime",
parseFormats: ["HH:mm"],
}).data("kendoTimePicker");
Controller:
public JsonResult Create(WorkTime worktime)
{
if (ModelState.IsValid)
{
try
{
db.WorkTimes.Add(worktime);
db.SaveChanges();
return Json(worktime, JsonRequestBehavior.AllowGet);
}
}
catch (Exception e)
{
return
Json(
HelperModel.GenerateErrorMessage(null,
"There is a problem while saving the created record. Please try again!"),
JsonRequestBehavior.AllowGet);
}
}
return Json(HelperModel.GenerateErrorMessage(ModelState), JsonRequestBehavior.AllowGet);
}
I want to save time to my problem is worktime.Fromtime always return {1/1/0001 12:00:00 AM}? anyone help me?