Hello ,
I am working on telerik winformc#,
I have one button its text is Delete and it will change on the event of one of my radiobutton to Re-Open.
on the click of that button function of that as below.
private void Delete()
{
if (File != null)
{
if (CloseOpenText == "Delete")
{
if (DialogResult.Yes == RadMessageBox.Show("Do you want to Delete selected File?", "Delete", MessageBoxButtons.YesNo, RadMessageIcon.Question))
{
this.File = _fileModel.Delete(_file);
BindData();
RadMessageBox.Show("Data has been deleted successfully", "Data Saved!", MessageBoxButtons.OK, RadMessageIcon.Info);
}
}
else
{
if (DialogResult.Yes == RadMessageBox.Show("Do you want to Re-Open selected File?", "Re-Open File", MessageBoxButtons.YesNo, RadMessageIcon.Question))
{
this.File = _fileModel.ReOpen(_file);
RadMessageBox.Show("File has been restore successfully", "File Re-Opened!", MessageBoxButtons.OK, RadMessageIcon.Info);
}
}
}
}
for the Re-Open functionality i have problem.
function of that as below.
public File ReOpen(File file)
{
file.ClosedFileNumber = string.Empty;
file.FileStatus = true;
//_repository.ApplyChanges(file);
Update(file);
// RaiseEvent(file, ChangeAction.Add);
//Audit trail
//TODO: MyAuditTrialModel.Add<File>(Helper.Actions.CU_File, Helper.TableNames.File, file);
return file;
}
for the update function is as below.
private File Update(File item)
{
_context.Files.ApplyChanges(item);
_context.ObjectStateManager.ChangeObjectState(item, System.Data.EntityState.Modified);
_context.SaveChanges(true);
return item;
}
I have find the error of
"AcceptChanges cannot continue because the object's key values conflict with another object in the ObjectStateManager. Make sure that the key values are unique before calling AcceptChanges".
error throws at
case (ObjectState.Unchanged):
context.ObjectStateManager.ChangeObjectState(entity, EntityState.Unchanged);
break;
help me for that