public static void SaveChapter(int id, string title, string text) { var entity = new CreativeNetworkEntities(); var chapter = entity.Chapter.FirstOrDefault(c => c.Id == id); chapter.Text = text; chapter.Name = title; entity.Chapter.Attach(chapter); entity.Entry(chapter).State = EntityState.Modified; entity.SaveChanges(); }
public static void ChangeNumber(int chapterId, int number) { var entity = new CreativeNetworkEntities(); var chapter = entity.Chapter.FirstOrDefault(c => c.Id == chapterId); chapter.Number = number; entity.Chapter.Attach(chapter); entity.Entry(chapter).State = EntityState.Modified; entity.SaveChanges(); }