public void UpdatePersona(PersonaDTO item) { p1p.Data.Persona mdlPersona = (p1p.Data.Persona)P1PObjectMapper.Convert(item, typeof(p1p.Data.Persona)); p1p.Data.Persona match; using (P1PContext ctx = new P1PContext()) { match = ctx.Personas.Single(p => p.Id == mdlPersona.Id); mdlPersona.InsertDate = match.InsertDate; ctx.Entry(match).CurrentValues.SetValues(mdlPersona); ctx.SaveChanges(); } }
public void AddPersona(PersonaDetailDTO item) { p1p.Data.Persona newPersona; p1p.Data.Persona mdlPersona = (p1p.Data.Persona)P1PObjectMapper.Convert(item, typeof(p1p.Data.Persona)); mdlPersona.InsertDate = DateTime.Now; using (P1PContext ctx = new P1PContext()) { newPersona = ctx.Personas.Add(mdlPersona); ctx.ProjectPersonaXREFs.Add(new ProjectPersonaXREF() { ProjectId = item.ProjectId, PersonaId = newPersona.Id, InsertDate = DateTime.Now }); ctx.SaveChanges(); } }