Exemplo n.º 1
0
        public PartialViewResult _LatestBlog()
        {
            using (MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities())
            {
                BlogsListViewModel blog = (from x in db.Blogs
                                           join y in db.Images on x.BlogImageID equals y.ImageID into ya
                                           from y in ya.DefaultIfEmpty()
                                           join z in db.Images on x.BlogThumbnailImageID equals z.ImageID into za
                                           from z in za.DefaultIfEmpty()
                                           orderby x.BlogDate
                                           select new BlogsListViewModel
                {
                    BlogID = x.BlogID,
                    BlogTitle = x.BlogTitle,
                    BlogAuthor = x.BlogAuthor,
                    BlogDate = x.BlogDate,
                    BlogSummary = x.BlogSummary,
                    BlogPost = x.BlogPost,
                    BlogImage = (y != null ? Settings.UPLOADSIMAGEFILEPATH + y.ImageFileName : Settings.DEFAULTIMAGEFILEPATH),
                    BlogThumbnail = (z != null ? Settings.UPLOADSIMAGEFILEPATH + z.ImageFileName : Settings.DEFAULTIMAGEFILEPATH),
                    IsDisabled = x.IsDisabled,
                    IsDeleted = x.IsDeleted,
                    BlogCreatedDate = x.BlogCreatedDate
                }).FirstOrDefault();

                return(PartialView(blog));
            }
        }
        public ActionResult Index(int?pageNumber)
        {
            if (User.Identity.IsAuthenticated)
            {
                int page = pageNumber != null ? (int)pageNumber : 1;

                using (MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities())
                {
                    List <ImageListViewModel> imageList = new List <ImageListViewModel>();

                    imageList = (from x in db.Images
                                 select new ImageListViewModel
                    {
                        ImageID = x.ImageID,
                        ImageFileName = x.ImageFileName,
                        ImageCreatedDate = x.ImageCreatedDate,
                        ImageModifiedDate = x.ModifiedDate,
                        IsDeleted = x.IsDeleted
                    }).ToList();

                    ViewBag.CurrentPage  = pageNumber;
                    ViewBag.CountOfItems = imageList.Count();

                    ViewBag.BodyClass = Settings.BodyClass.IMAGES;
                    return(View(imageList.Skip((page - 1) * Settings.PAGINATIONITEMSPERPAGE).Take(Settings.PAGINATIONITEMSPERPAGE).ToList()));
                }
            }

            return(HttpNotFound());
        }
Exemplo n.º 3
0
        public PartialViewResult _LatestProject()
        {
            using (MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities())
            {
                //var project = db.Projects.OrderBy(x => x.ProjectPostDate).Take(1).SingleOrDefault();
                ProjectsListViewModel project = (from x in db.Projects
                                                 join y in db.Images on x.ProjectImageID equals y.ImageID into ya
                                                 from y in ya.DefaultIfEmpty()
                                                 join z in db.Images on x.ProjectThumbnailImageID equals z.ImageID into za
                                                 from z in za.DefaultIfEmpty()
                                                 orderby x.ProjectPostDate
                                                 select new ProjectsListViewModel
                {
                    ProjectID = x.ProjectID,
                    ProjectTitle = x.ProjectTitle,
                    ProjectDateDescription = x.ProjectDateDescription,
                    ProjectPostDate = x.ProjectPostDate,
                    ProjectSummary = x.ProjectSummary,
                    ProjectDescription = x.ProjectDescription,
                    ProjectLink = x.ProjectLink,
                    ProjectImage = (y != null ? Settings.UPLOADSIMAGEFILEPATH + y.ImageFileName : Settings.DEFAULTIMAGEFILEPATH),
                    ProjectThumbnailImage = (z != null ? Settings.UPLOADSIMAGEFILEPATH + z.ImageFileName : Settings.DEFAULTIMAGEFILEPATH),
                    IsDisabled = x.IsDisabled,
                    IsDeleted = x.IsDeleted,
                    ProjectCreatedDate = x.ProjectCreatedDate
                }).FirstOrDefault();

                return(PartialView(project));
            }
        }
        public ActionResult Index(int?page)
        {
            int pageNumber = page != null ? (int)page : 1;

            using (MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities())
            {
                var blogs = (from x in db.Blogs
                             join y in db.Images on x.BlogImageID equals y.ImageID into ya
                             from y in ya.DefaultIfEmpty()
                             join z in db.Images on x.BlogThumbnailImageID equals z.ImageID into za
                             from z in za.DefaultIfEmpty()
                             where !x.IsDisabled && !x.IsDeleted
                             orderby x.BlogDate descending
                             select new BlogsListViewModel
                {
                    BlogID = x.BlogID,
                    BlogTitle = x.BlogTitle,
                    BlogAuthor = x.BlogAuthor,
                    BlogDate = x.BlogDate,
                    BlogSummary = x.BlogSummary,
                    BlogPost = x.BlogPost,
                    BlogImage = (y != null ? Settings.UPLOADSIMAGEFILEPATH + y.ImageFileName : Settings.DEFAULTIMAGEFILEPATH),
                    BlogThumbnail = (z != null ? Settings.UPLOADSIMAGEFILEPATH + z.ImageFileName : Settings.DEFAULTIMAGEFILEPATH),
                    IsDisabled = x.IsDisabled,
                    IsDeleted = x.IsDeleted,
                    BlogCreatedDate = x.BlogCreatedDate
                }).ToList();

                ViewBag.CurrentPage  = pageNumber;
                ViewBag.CountOfItems = blogs.Count();
                ViewBag.BodyClass    = Settings.BodyClass.BLOGS;

                return(View(blogs.Skip((pageNumber - 1) * Settings.PAGINATIONITEMSPERPAGE).Take(Settings.PAGINATIONITEMSPERPAGE).ToList()));
            }
        }
        public ActionResult View(string year, string month, string title)
        {
            int blogYear  = 0;
            int blogMonth = 0;

            if (int.TryParse(year, out blogYear) && int.TryParse(month, out blogMonth))
            {
                using (MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities())
                {
                    var blogs = (from x in db.Blogs
                                 join y in db.Images on x.BlogImageID equals y.ImageID into ya
                                 from y in ya.DefaultIfEmpty()
                                 join z in db.Images on x.BlogThumbnailImageID equals z.ImageID into za
                                 from z in za.DefaultIfEmpty()
                                 where !x.IsDisabled && !x.IsDeleted
                                 orderby x.BlogDate descending
                                 select new BlogsListViewModel
                    {
                        BlogID = x.BlogID,
                        BlogTitle = x.BlogTitle,
                        BlogAuthor = x.BlogAuthor,
                        BlogDate = x.BlogDate,
                        BlogSummary = x.BlogSummary,
                        BlogPost = x.BlogPost,
                        BlogImage = (y != null ? Settings.UPLOADSIMAGEFILEPATH + y.ImageFileName : ""),
                        BlogThumbnail = (z != null ? Settings.UPLOADSIMAGEFILEPATH + z.ImageFileName : ""),
                        IsDisabled = x.IsDisabled,
                        IsDeleted = x.IsDeleted,
                        BlogCreatedDate = x.BlogCreatedDate
                    }).ToList();


                    var blog = blogs.Where(x => x.BlogDate.Year == blogYear && x.BlogDate.Month == blogMonth && Code.UsefulFunctions.SafeURL(x.BlogTitle) == title).SingleOrDefault();

                    if (blog != null)
                    {
                        ViewBag.BodyClass = Settings.BodyClass.DETAILSPAGE;
                        return(View(blog));
                    }
                }
            }

            return(RedirectToAction("Index", "Blogs"));
        }
Exemplo n.º 6
0
        public static List <Blog> GetBlogs(bool showDisabled, bool showDeleted)
        {
            using (MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities())
            {
                List <Blog> blogs = db.Blogs.ToList();

                if (!showDisabled)
                {
                    blogs = blogs.Where(x => !x.IsDisabled).ToList();
                }

                if (!showDeleted)
                {
                    blogs = blogs.Where(x => !x.IsDeleted).ToList();
                }

                return(blogs);
            }
        }
Exemplo n.º 7
0
        //public static MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities();

        //public static List<Image> GetImages(bool showDeleted)
        //{
        //    List<Image> images = db.Images.ToList();

        //    if(!showDeleted)
        //    {
        //        images = images.Where(x => !x.IsDeleted).ToList();
        //    }

        //    return images;
        //}

        public static List <Project> GetProjects(bool showDisabled, bool showDeleted)
        {
            using (MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities())
            {
                List <Project> projects = db.Projects.ToList();

                if (!showDisabled)
                {
                    projects = projects.Where(x => !x.IsDisabled).ToList();
                }

                if (!showDeleted)
                {
                    projects = projects.Where(x => !x.IsDeleted).ToList();
                }

                return(projects);
            }
        }
Exemplo n.º 8
0
        public ActionResult View(string year, string month, string title)
        {
            int blogYear  = 0;
            int blogMonth = 0;

            if (int.TryParse(year, out blogYear) && int.TryParse(month, out blogMonth))
            {
                using (MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities())
                {
                    var projects = (from x in db.Projects
                                    join y in db.Images on x.ProjectImageID equals y.ImageID
                                    join z in db.Images on x.ProjectThumbnailImageID equals z.ImageID
                                    where !x.IsDisabled && !x.IsDeleted
                                    orderby x.ProjectPostDate
                                    select new ProjectsListViewModel
                    {
                        ProjectID = x.ProjectID,
                        ProjectTitle = x.ProjectTitle,
                        ProjectDateDescription = x.ProjectDateDescription,
                        ProjectPostDate = x.ProjectPostDate,
                        ProjectSummary = x.ProjectSummary,
                        ProjectDescription = x.ProjectDescription,
                        ProjectLink = x.ProjectLink,
                        ProjectImage = Settings.UPLOADSIMAGEFILEPATH + y.ImageFileName,
                        ProjectThumbnailImage = Settings.UPLOADSIMAGEFILEPATH + z.ImageFileName,
                        IsDisabled = x.IsDisabled,
                        IsDeleted = x.IsDeleted,
                        ProjectCreatedDate = x.ProjectCreatedDate
                    }).ToList();

                    var project = projects.Where(x => x.ProjectPostDate.Year == blogYear && x.ProjectPostDate.Month == blogMonth && Code.UsefulFunctions.SafeURL(x.ProjectTitle) == title).SingleOrDefault();

                    if (project != null)
                    {
                        ViewBag.BodyClass = Settings.BodyClass.DETAILSPAGE;
                        return(View(project));
                    }
                }
            }

            return(RedirectToAction("Index", "Projects"));
        }
Exemplo n.º 9
0
        public static List <ImageViewModel> GetImages(bool showDeleted)
        {
            using (MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities())
            {
                List <ImageViewModel> images = (from x in db.Images
                                                select new ImageViewModel
                {
                    ImageID = x.ImageID,
                    FileName = x.ImageFileName,
                    CreatedDate = x.ImageCreatedDate,
                    IsDeleted = x.IsDeleted,
                    ModifiedBy = x.ModifiedBy,
                    ModifiedDate = x.ModifiedDate
                }).ToList();

                if (!showDeleted)
                {
                    images = images.Where(x => !x.IsDeleted).ToList();
                }

                return(images);
            }
        }
Exemplo n.º 10
0
        public ActionResult Index(int?page)
        {
            int pageNumber = page != null ? (int)page : 1;

            using (MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities())
            {
                var projects = (from x in db.Projects
                                join y in db.Images on x.ProjectImageID equals y.ImageID into ya
                                from y in ya.DefaultIfEmpty()
                                join z in db.Images on x.ProjectThumbnailImageID equals z.ImageID into za
                                from z in za.DefaultIfEmpty()
                                where !x.IsDisabled && !x.IsDeleted
                                orderby x.ProjectPostDate descending
                                select new ProjectsListViewModel
                {
                    ProjectID = x.ProjectID,
                    ProjectTitle = x.ProjectTitle,
                    ProjectDateDescription = x.ProjectDateDescription,
                    ProjectPostDate = x.ProjectPostDate,
                    ProjectSummary = x.ProjectSummary,
                    ProjectDescription = x.ProjectDescription,
                    ProjectLink = x.ProjectLink,
                    ProjectImage = (y != null ? Settings.UPLOADSIMAGEFILEPATH + y.ImageFileName : Settings.DEFAULTIMAGEFILEPATH),
                    ProjectThumbnailImage = (z != null ? Settings.UPLOADSIMAGEFILEPATH + z.ImageFileName : Settings.DEFAULTIMAGEFILEPATH),
                    IsDisabled = x.IsDisabled,
                    IsDeleted = x.IsDeleted,
                    ProjectCreatedDate = x.ProjectCreatedDate
                }).ToList();

                ViewBag.CurrentPage  = pageNumber;
                ViewBag.CountOfItems = projects.Count();
                ViewBag.BodyClass    = Settings.BodyClass.PROJECTS;

                return(View(projects.Skip((pageNumber - 1) * 10).Take(10).ToList()));
            }
        }