Пример #1
0
        public static List <Album> GetAll(int postID)
        {
            using (SlickCMSDataContext db = SlickCMSDataContext.Create())
            {
                var query = (
                    from a in db.Albums
                    where a.PostID == postID
                    orderby a.Rank ascending
                    select a
                    );

                List <Album> albums = query.ToList();

                if (albums.Count == 0)
                {
                    return(albums);
                }

                foreach (Album album in albums)
                {
                    var imageQuery = (
                        from i in db.Images
                        where i.AlbumID == album.AlbumID
                        orderby i.Main descending
                        select i
                        );

                    album.MainImage = imageQuery.FirstOrDefault();
                }

                return(albums);
            }
        }
Пример #2
0
        public void Update()
        {
            SlickCMSDataContext dc = SlickCMSDataContext.Create();

            Property property = dc.Properties.Single(p => p.PropertyID == this.PropertyID);

            property.Reference       = this.Reference;
            property.SaleType        = this.SaleType;
            property.PropertyType    = this.PropertyType;
            property.Address1        = this.Address1;
            property.Address2        = this.Address2;
            property.Address3        = this.Address3;
            property.Address4        = this.Address4;
            property.PostCode        = this.PostCode;
            property.Price           = this.Price;
            property.Parking         = this.Parking;
            property.Garages         = this.Garages;
            property.Receptions      = this.Receptions;
            property.Bedrooms        = this.Bedrooms;
            property.Bathrooms       = this.Bathrooms;
            property.Garden          = this.Garden;
            property.Pets            = this.Pets;
            property.Conservatory    = this.Conservatory;
            property.Furnishings     = this.Furnishings;
            property.Summary         = this.Summary;
            property.FullDescription = this.FullDescription;
            property.KeyFeatures     = this.KeyFeatures;
            property.RightMoveURL    = this.RightMoveURL;
            property.DateModified    = DateTime.Now;
            property.Published       = this.Published;
            property.Tagline         = this.Tagline;

            dc.SubmitChanges();
            dc.Dispose();
        }
Пример #3
0
 public static Album Get(int albumID)
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         return(db.Albums.Where(p => p.AlbumID == albumID).FirstOrDefault());
     }
 }
Пример #4
0
        public static List <string> SelectFurnishings()
        {
            SlickCMSDataContext dc = SlickCMSDataContext.Create();
            var query = (from p in dc.Properties orderby p.Furnishings ascending select p.Furnishings.ToString()).Distinct();

            return(query.ToList());
        }
Пример #5
0
            public static List <PostSummary> GetArchived(int postID)
            {
                using (SlickCMSDataContext db = SlickCMSDataContext.Create())
                {
                    var query = (
                        from p in db.Posts
                        where
                        p.Archive != null &&
                        p.Published == 1 &&
                        p.Pageable == 0 &&
                        !p.Deleted &&
                        p.ParentPage == postID
                        orderby p.Rank
                        select new PostSummary
                    {
                        PostID = p.PostID,
                        Title = p.Title,
                        URL = p.URL,
                        ParentPage = p.ParentPage,
                        Archive = p.Archive,
                    }
                        );

                    return(query.ToList());
                }
            }
Пример #6
0
        public void Delete()
        {
            SlickCMSDataContext dc = SlickCMSDataContext.Create();

            dc.ExecuteCommand("Delete From Documents Where DocumentID = {0}", this.DocumentID);
            dc.Dispose();
        }
Пример #7
0
 public void Delete()
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         db.ExecuteCommand("Delete From Links Where LinkID = {0}", this.LinkID);
     }
 }
Пример #8
0
 public static Comment Get(int commentID)
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         return(db.Comments.Where(c => c.CommentID == commentID).FirstOrDefault());
     }
 }
Пример #9
0
        /// <summary>
        /// Searches Properties using a specified search
        /// </summary>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <param name="search">Search query</param>
        /// <returns></returns>
        public List <Property> SelectMultiple(int skip, int take, string search)
        {
            search = search.ToLower(); //case insensitive searching

            SlickCMSDataContext dc = SlickCMSDataContext.Create();

            var query = (
                from p in dc.Properties
                where
                p.SaleType.Contains(search) ||
                p.PropertyType.Contains(search) ||
                p.Price.ToString().Contains(search) ||
                //p.Bedrooms.ToString().Contains(search) ||
                //p.Bathrooms.ToString().Contains(search) ||
                p.Furnishings.Contains(search) ||
                p.Address2.Contains(search) ||
                p.Address3.Contains(search) ||
                p.Address4.Contains(search) ||
                p.FullDescription.Contains(search) ||
                p.KeyFeatures.Contains(search) ||
                p.Summary.Contains(search) ||
                p.PostCode.Contains(search)
                select p
                );

            query = query.OrderByDescending(p => p.DateModified);

            return(query.Skip(skip).Take(take).ToList());
        }
Пример #10
0
        public void Delete(string path)
        {
            /*SlickCMSDataContext dc = SlickCMSDataContext.Create();
             * dc.ExecuteCommand("Delete From Images Where ImageID = {0}", this.ImageID);
             * dc.Dispose();*/

            using (SlickCMSDataContext db = SlickCMSDataContext.Create())
            {
                var obj = (from i in db.Images where i.ImageID == this.ImageID select i).FirstOrDefault();
                db.Images.DeleteOnSubmit(obj);
                db.SubmitChanges();
            }

            if (path.Length > 0)
            {
                string file = path + "[folder]\\" + this.Name + this.Extension;

                string thumbImage    = file.Replace("[folder]", "thumb");
                string largeImage    = file.Replace("[folder]", "large");
                string originalImage = file.Replace("[folder]", "original");

                if (File.Exists(thumbImage))
                {
                    File.Delete(thumbImage);
                }
                if (File.Exists(largeImage))
                {
                    File.Delete(largeImage);
                }
                if (File.Exists(originalImage))
                {
                    File.Delete(originalImage);
                }
            }
        }
Пример #11
0
        public Post Select(string archive, string url)
        {
            using (SlickCMSDataContext dc = SlickCMSDataContext.Create())
            {
                var query = (
                    from p in dc.Posts
                    where
                    p.URL == url &&
                    !p.Deleted &&
                    p.Archive == archive
                    select p
                    );

                Post post = query.FirstOrDefault();

                if (post == null)
                {
                    // TODO: show 404 page
                    query = (from p in dc.Posts where p.URL == "404" select p);
                    post  = query.FirstOrDefault();
                }

                return(post);
            }
        }
Пример #12
0
 public static Newsletter Get(int newsletterID)
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         return(db.Newsletters.Where(p => p.NewsletterID == newsletterID).FirstOrDefault());
     }
 }
Пример #13
0
        public Post Select(string url)
        {
            SlickCMSDataContext dc = SlickCMSDataContext.Create();
            var query = (
                from p in dc.Posts
                where
                p.URL == url &&
                !p.Deleted &&
                p.Archive == null       // excluding archived posts, as they should now be retrieved using Select() passing in archive
                select p
                );
            Post post = query.FirstOrDefault();

            //Post post = dc.Posts.SingleOrDefault(p => p.URL == url);

            if (post == null)
            {
                //show 404 page
                // TODO: 404 is no longer stored within database - specify it as a static post object defined within this class?
                query = (from p in dc.Posts where p.URL == "404" select p);
                post  = query.FirstOrDefault();
                //post = dc.Posts.SingleOrDefault(p => p.URL == "404");
            }

            return(post);
        }
Пример #14
0
 public static Event Get(int eventID)
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         return(db.Events.Where(e => e.EventID == eventID).FirstOrDefault());
     }
 }
Пример #15
0
 public static User Get(int userID)
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         return(db.Users.Where(u => u.UserID == userID).FirstOrDefault());
     }
 }
Пример #16
0
        /// <summary>
        /// Gets all images
        /// </summary>
        /// <param name="postID">Set to ID of the Post, to retrieve all of its images</param>
        /// <returns></returns>
        public static List <Image> GetAll(int albumID)
        {
            using (SlickCMSDataContext db = SlickCMSDataContext.Create())
            {
                var query = (
                    from i in db.Images
                    where i.AlbumID == albumID
                    select i
                    );

                /*if (albumID > 0)
                 * {
                 *  query = query.Where(p => p.AlbumID == albumID);
                 * }*/

                if (albumID == 0)
                {
                    query = query.OrderBy(i => i.Title);
                }
                else
                {
                    query = query.OrderBy(i => i.Rank);
                }

                return(query.ToList());
            }
        }
Пример #17
0
            public static List <PostSummary> SelectSubPages(int parentPage)
            {
                SlickCMSDataContext dc = SlickCMSDataContext.Create();

                var query = (
                    from p in dc.Posts
                    where
                    1 == 1
                    //&& p.Published == 1
                    && p.ParentPage == parentPage &&
                    p.Pageable == 0 &&
                    !p.Deleted
                    //&& p.Archive == null
                    orderby p.Rank ?? 0 ascending
                    select new PostSummary
                {
                    Title = p.Title,
                    URL = p.URL,
                    PostID = p.PostID,
                    Published = (p.Published == 1),
                    Archive = p.Archive,
                }
                    );

                return(query.ToList());
            }
Пример #18
0
            public static List <PostSummary> SelectNavigation()
            {
                string[] excludedPages = { "terms-and-conditions", "child-protection-policy" }; // titles to exclude from navigation

                SlickCMSDataContext dc = SlickCMSDataContext.Create();

                var query = (
                    from p in dc.Posts
                    where
                    1 == 1
                    //&& p.Published == 1
                    && p.Pageable == 0 &&
                    !excludedPages.Contains(p.URL) &&
                    p.ParentPage == 0 &&    // exclude sub-pages and nulls
                    !p.Deleted
                    //&& p.Archive == null
                    //orderby p.Title ascending// TODO: implement ordering
                    orderby p.Rank ?? 0 ascending
                    select new PostSummary
                {
                    PostID = p.PostID,
                    Title = p.Title,
                    URL = p.URL,
                    ParentPage = p.ParentPage,
                    Archive = p.Archive,
                    Published = (p.Published == 1),
                }
                    );

                return(query.ToList());
            }
Пример #19
0
 public static Link Get(int linkID)
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         return(db.Links.Where(p => p.LinkID == linkID).FirstOrDefault());
     }
 }
Пример #20
0
 public void Add()
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         db.Newsletters.InsertOnSubmit(this);
         db.SubmitChanges();
     }
 }
Пример #21
0
 public void Add()
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         db.Announcements.InsertOnSubmit(this);
         db.SubmitChanges();
     }
 }
Пример #22
0
 public static int CountPublished()
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         var query = (from ni in db.NewsItems where ni.Published == 1 select ni);
         return(query.Count());
     }
 }
Пример #23
0
        /// <summary>
        /// Gets the ID of the latest Post, useful for carrying out further operations
        /// </summary>
        /// <returns>ID of the latest Post</returns>

        /*public int SelectPostID()
         * {
         *  SlickCMSDataContext dc = SlickCMSDataContext.Create();
         *  return (from p in dc.Posts orderby p.PostID descending select p.PostID).FirstOrDefault();
         * }*/

        /// <summary>
        /// Retrieves a list of Post titles
        /// </summary>
        /// <returns>List of PostTitle</returns>
        public List <PostTitle> SelectPostTitles()
        {
            SlickCMSDataContext dc = SlickCMSDataContext.Create();

            return((from p in dc.Posts where !p.Deleted select new PostTitle {
                Title = p.Title
            }).Distinct().OrderBy(p => p.Title).ToList());
        }
Пример #24
0
 public void Insert()
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         db.Links.InsertOnSubmit(this);
         db.SubmitChanges();
     }
 }
Пример #25
0
 public static string SelectPostTitle(int postID)
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         var query = (from p in db.Posts where p.PostID == postID select p.Title);
         return(query.FirstOrDefault());
     }
 }
Пример #26
0
 public static int CountBlogPosts()
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         var query = (from p in db.Posts where p.Pageable == 1 && p.Published == 1 select p);
         return(query.Count());
     }
 }
Пример #27
0
        /// <summary>
        /// Deletes an existing Comment
        /// </summary>
        public void Delete()
        {
            SlickCMSDataContext dc = SlickCMSDataContext.Create();

            dc.Comments.DeleteOnSubmit(this);
            dc.SubmitChanges();
            dc.Dispose();
        }
Пример #28
0
        private void LogToDatabase()
        {
            SlickCMSDataContext db = SlickCMSDataContext.Create();

            db.Logs.InsertOnSubmit(this);
            db.SubmitChanges();
            db.Dispose();
        }
Пример #29
0
 public void Delete()
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         Event obj = (from e in db.Events where e.EventID == this.EventID select e).FirstOrDefault();
         db.Events.DeleteOnSubmit(obj);
         db.SubmitChanges();
     }
 }
Пример #30
0
 public void Delete()
 {
     using (SlickCMSDataContext db = SlickCMSDataContext.Create())
     {
         Newsletter obj = (from n in db.Newsletters where n.NewsletterID == this.NewsletterID select n).FirstOrDefault();
         db.Newsletters.DeleteOnSubmit(obj);
         db.SubmitChanges();
     }
 }