I'm having a couple of problems with an API in ASP.Net, I try to save data like this:
public HttpResponseMessage PostExpediente([FromBody] ExpedienteDto expedientePOCO)
{
Ejercicio2Entities context = new Ejercicio2Entities();
using (context)
{
Expediente expediente = new Expediente();
expediente.idExpediente = expedientePOCO.idExpediente;
expediente.NombreExpediente = expedientePOCO.NombreExpediente;
expediente.FechaCreacion = expedientePOCO.FechaCreacion;
expediente.DuenioExpediente = expedientePOCO.DuenioExpediente;
expediente.CantidadDocumento = expedientePOCO.Documentos.Count;
if (expediente.Documento.Count == 0)
db.Expediente.Add(expediente);
context.SaveChanges();
context.Database.Log = msg => Trace.WriteLine(msg);
}
return Request.CreateResponse(HttpStatusCode.OK);
}
The parameter passed it this way through POSTMAN:
{
"idExpediente": 0,
"NombreExpediente": "Expediente A",
"FechaCreacion": "2018-01-19T09:25:25.717",
"DuenioExpediente": "Alex",
"CantidadDocumento": 0
}
The api successfully receives the parameter, is correctly assigned to the EF entity, successfully passes to the ObjectContext.SaveChanges () but does not do the saving. It does not give an error or anything, it just does not work. Any ideas?