public async Task <ActionResult> Assign([Bind(Include = "ID,EmployeeList,ItemList,MeasuringDeviceList,VehicleList")] AssignmentAssignViewModel assignment) { try { if (assignment == null) { return(RedirectToAction("Assign", new { ID = assignment.ID })); } if (ModelState.IsValid) { foreach (var emp in assignment.EmployeeList) { if (emp.isSelected) { AssignmentParameters.EmployeeList.Add(new BaseEntity() { ID = emp.ID }); } } await Service.AssignAsync(AssignmentParameters); return(RedirectToAction("Details", new { ID = assignment.ID })); } } catch (DataException) { ModelState.AddModelError("", "Unable to save changes. Try again and if the problem persists see your system administrator."); } return(RedirectToAction("Assign", new { ID = assignment.ID })); }