public NewsSnippet Update(NewsSnippet updatedNewsSnippet) { var NewsSnippet = context.NewsSnippets.Attach(updatedNewsSnippet); NewsSnippet.State = Microsoft.EntityFrameworkCore.EntityState.Modified; context.SaveChanges(); return(updatedNewsSnippet); }
public void OnGet(int id) { this.NewsSnippet = newsSnippetRepository.GetNewsSnippet(id); NewsSnippetForward = newsSnippetRepository.GetNewsSnippet(id + 1); NewsSnippetBackward = newsSnippetRepository.GetNewsSnippet(id - 1); }
public NewsSnippet AddNewsSnippet(NewsSnippet newNewsSnippet) { context.Database.ExecuteSqlRaw("spInsertNewsSnippet {0},{1},{2}", newNewsSnippet.Title, newNewsSnippet.Date, newNewsSnippet.Description); return(newNewsSnippet); }
public NewsSnippet Delete(int id) { NewsSnippet NewsSnippet = context.NewsSnippets.Find(id); if (NewsSnippet != null) { context.NewsSnippets.Remove(NewsSnippet); context.SaveChanges(); } return(NewsSnippet); }