private void FixupWebNoticias(WebNoticias previousValue) { if (previousValue != null && previousValue.WebNoticiasArchivos.Contains(this)) { previousValue.WebNoticiasArchivos.Remove(this); } if (WebNoticias != null) { if (!WebNoticias.WebNoticiasArchivos.Contains(this)) { WebNoticias.WebNoticiasArchivos.Add(this); } if (WebNoticiasId != WebNoticias.WebNoticiasId) { WebNoticiasId = WebNoticias.WebNoticiasId; } } }
public int UpdateNoticia(WebNoticias noticia) { using (var context = new QuirofanoEntities()) { //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 QuirofanoEntities()) { context.WebNoticias.AddObject(noticia); context.SaveChanges(); return noticia.WebNoticiasId; } }