public void AddPost(int ID) { if (!Posts.Contains(ID)) { Posts.Add(ID); } }
public void RemovePost(int ID) { if (Posts.Contains(ID)) { Posts.Remove(ID); } }
/// <summary> /// Deletes the Post from the current BlogProvider. /// </summary> public void Purge() { BlogService.DeletePost(this); if (!Posts.Contains(this)) { // refresh posts list posts = null; deletedposts = null; return; } Posts.Remove(this); this.Dispose(); AddRelations(); // refresh posts list posts = null; deletedposts = null; }
/// <summary> /// Initializes the region. /// </summary> /// <param name="model">The current page model.</param> public virtual void Init(object model) { using (var db = new DataContext()) { // Get the currently attached posts var posts = db.Posts.Include(p => p.Template).Include(p => p.Categories).Where(p => Posts.Contains(p.Id)).ToList(); foreach (var id in Posts) { var post = posts.Where(p => p.Id == id).SingleOrDefault(); if (posts != null) { Current.Add(post); } } // Get all of the available posts. Available = db.Posts.Include(p => p.Template).OrderBy(p => p.Template.Name).ThenBy(p => p.Title).ToList(); } }