public int UpdateNoticia(WebNoticias noticia) { using (var context = new AEPEntities()) { //WebNoticias noticiaUp = context.WebNoticias.First(i => i.WebNoticiasId == noticia.WebNoticiasId); //noticiaUp.Fecha = noticia.Fecha; //noticiaUp.Titulo = noticia.Titulo; //noticiaUp.Resumen = noticia.Resumen; //noticiaUp.Estado = noticia.Estado; //noticiaUp.Contenido = noticia.Contenido; //noticiaUp.Autor = noticia.Autor; //noticiaUp.WebMenuId = noticia.WebMenuId; //context.SaveChanges(); context.WebNoticias.Attach(context.WebNoticias.Single(i => i.WebNoticiasId == noticia.WebNoticiasId)); context.WebNoticias.ApplyCurrentValues(noticia); int inte = context.SaveChanges(SaveOptions.DetectChangesBeforeSave); return noticia.WebNoticiasId; } }
public int SaveNoticia(WebNoticias noticia) { using (var context = new AEPEntities()) { context.WebNoticias.AddObject(noticia); context.SaveChanges(); return noticia.WebNoticiasId; } }