I have a view called as 'EditEmployee'- which provides user to update the employee record. and have the field: EmployeeStatus with enum values Working, Retired.
- If an employee status is retired, all the benefits will be deleted. So I want to show the list of benefits the employee was having in the modal dialog. Else I want to update other fields which are changed in this view.
To do this, I am using a modal:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Confirm</h4>
</div>
<div class="modal-body">
@if(Model.EmployeeStatus== Employee.Retired)
{
<h5>Do you want to delete following benefits</h5>
<div class="displayBenefits">
<ul>
foreach(var item in Model.BenefitList)
{
<li>item</li>
}
</ul>
</div>
}
else
{
<h5>Are you sure you want to update? </h5>
}
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" id="ok">OK</button>
<button type="button" class="btn btn-default" data-dismiss="modal" id="cancel">Cancel</button>
</div>
</div>
</div>
</div>
and
viewModel.BenefitList= GetBenefitList(employeeDetails.EmployeeStatus);
private List<string> GetBenefitList(EmployeeStatus mystatus)
{
List<string> benefits= new List<string>();
if (mystatus == Employee.Retired)
{
benefits.Add("benefit 1");
benefits.Add("benefit 2");
benefits.Add("benefit 3");
benefits.Add("benefit 4");
}
return benefits;
}
The problem I am facing is, Before editing in that page, The modal is preloaded with the message: Are you sure you want to update?
once I change the EmployeeStatus to retired, and click on confirm button, I get the message
Are you sure you want to update? with OK and cancel in the modal
instead of displaying Do you want to delete following benefits benefit 1 benefit 2 benefit 3 benefit 4
Aucun commentaire:
Enregistrer un commentaire