If you want to do this without asking for your level of stability, I think adding the old values โโas fields in your model and then storing them on the page, as hidden fields is the easiest way to solve this problem.
Add CurrentStartDate and CurrentDuration to your model:
public class Project { public int ID { get; set; } //... some more properties public DateTime StartDate { get; set; } public int Duration { get; set; } public DateTime CurrentStartDate { get; set; } public int CurrentDuration { get; set; } }
and then add hidden fields with old values โโin your view:
@Html.HiddenFor(model => model.CurrentStartDate ) @Html.HiddenFor(model => model.CurrentDuration )
This will give you the opportunity to compare the selected values โโwith the action of your controller.
source share