[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "ID,FromTime,ToTime,CustomerID,UserID,Description,Type,CreatedTime")] Schedule schedule)
{
if (ModelState.IsValid)
{
db.Entry(schedule).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Name", schedule.CustomerID);
ViewBag.UserID = new SelectList(db.Users, "ID", "Name", schedule.UserID);
//return View(schedule);
return RedirectToRoute("Default", new { controller = "Schedules", action = "Index" });
}
<div class="form-group">
@Html.LabelFor(model => model.FromTime, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.FromTime, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.FromTime, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ToTime, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ToTime, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ToTime, "", new { @class = "text-danger" })
</div>
</div>
FromTime
andのタイプToTime
は長いので、それを Time として表示してから、できるだけ長く保存したいと考えています。
データベースに long 型があり、それを Model View Controller ASP.Net で Time として表示する必要がある場合は、データベースに long として再度保存します。これどうやってするの?