私はこれに非常に慣れておらず、プログラミングを必要としない仕事のためにプログラミングを引き受けているので、優しくしてください. :)
このアプリケーションは MVC 3 にあり、最初の日付に依存する他の 2 つの日付を作成するのに最適なコードがあります。ただし、最初の日付は null 可能です。このコードを追加する前は、フィールドに入力しなくてもアイテムを作成できました。現在は、フィールドを空白のままにしておくと失敗します。私は何を間違っていますか?
[HttpPost]
public ActionResult Create(Procedure procedure)
{
if (ModelState.IsValid)
{
context.Procedures.Add(procedure);
if (procedure.Effective != DateTime.MinValue)
{
procedure.ScheduledReview = procedure.Effective.Value.AddMonths(-1);
procedure.UserReview = procedure.Effective.Value.AddMonths(-3);
}
context.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.PossibleProTypes = context.ProTypes;
ViewBag.PossibleStatus = context.Status;
ViewBag.PossiblePendingActions = context.PendingActions;
ViewBag.PossibleOffices = context.Offices;
return View(procedure);
}