When I add a record to my Include screen, this error appears to me.
What can it be?
Service
public void AddItem(Test item)
{
var codigos = this.context.Tests.SingleOrDefault(x => x.Codigo == item.Codigo);
if (codigos != null)
{
this.context.Testes.Any(x =>
x.Id == codigos.Id
&& x.Codigo != item.Codigo);
throw new ValidationException("Codigo", Resources.TestesResources.ErroUniqueKeyCodigo);
}
else
{
base.context.Tests.Add(item);
base.Save();
}
}
Controller
[HttpPost]
public ActionResult Incluir([ModelBinder(typeof(CollectionModelBinder))]Testitem)
{
if (this.ModelState.IsValid)
{
item.Id = this.Id;
item.Value = DateTime.Now;
item.Use = User;
try
{
this.Service.AddItem(item);
return this.SuccessView(true);
}
catch (ValidationException exception)
{
base.AddValidationErrors(exception);
return base.PartialView(item);
}
}
else
return base.PartialView(item);
}
Error