예제 #1
0
        public ActionResult ViewBlogFromExtern(string userid, string blogid)
        {
            var  userdata = userid.Split(':');
            Guid blogguid;

            try {
                blogguid = new Guid(blogid);
            }catch (FormatException e)
            {
                return(null);
            }
            var uderid = userdata[0];
            ApplicationDbContext context = new ApplicationDbContext();

            if (context.BlogDatas.Any(blog => blog.ApplicationUserId == uderid && blog.ExternalId == blogguid))
            {
                var blogdata = context.BlogDatas.Where(blog => blog.ApplicationUserId == uderid && blog.ExternalId == blogguid).ToList().Single();


                List <Element> elements = GenerateElements(blogdata.GalleryModels, blogdata.ImageModels, blogdata.TextModels, blogdata.VideoModels);
                elements = elements.OrderBy(x => x.position).ToList();

                bool gmapsVisibility = false;
                if (blogdata.GMapsMarkerModels.Count > 0)
                {
                    gmapsVisibility = true;
                }

                var viewmodel = new ExternBlogViewModel {
                    Title = blogdata.Title, Subtitle = blogdata.Subtitle, Elements = elements, IsGoogleMapsVisible = gmapsVisibility
                };


                return(View(viewmodel));
            }


            return(null);
        }
예제 #2
0
        public ActionResult ShowBlog(int?id)
        {
            if (id != null)
            {
                ApplicationDbContext context = new ApplicationDbContext();
                var user = context.Users.Find(User.Identity.GetUserId());

                if (user != null && context.BlogDatas.Any(blog => blog.ApplicationUserId == user.Id && blog.BlogDataId == id))
                {
                    var blogdata = context.BlogDatas.Where(blog => blog.ApplicationUserId == user.Id && blog.BlogDataId == id).ToList().Single();

                    List <Element> elements = GenerateElements(blogdata.GalleryModels, blogdata.ImageModels, blogdata.TextModels, blogdata.VideoModels);
                    elements = elements.OrderBy(x => x.position).ToList();

                    bool gmapsVisibility = false;
                    if (blogdata.GMapsMarkerModels.Count > 0)
                    {
                        gmapsVisibility = true;
                    }


                    var viewmodel = new ExternBlogViewModel {
                        Title = blogdata.Title, Subtitle = blogdata.Subtitle, Elements = elements, IsGoogleMapsVisible = gmapsVisibility
                    };


                    return(View(viewmodel));
                }
                else
                {
                    return(RedirectToAction("Overview", "Blog"));
                }
            }
            else
            {
                return(RedirectToAction("Overview", "Blog"));
            }
        }
예제 #3
0
        public ActionResult Edit(int?id)
        {
            if (id != null)
            {
                ApplicationDbContext context = new ApplicationDbContext();
                var user = context.Users.Find(User.Identity.GetUserId());

                if (user != null && context.BlogDatas.Any(blog => blog.ApplicationUserId == user.Id && blog.BlogDataId == id))
                {
                    var blogdata = context.BlogDatas.Where(blog => blog.ApplicationUserId == user.Id && blog.BlogDataId == id).ToList().Single();

                    List <Element> elements = GenerateElements(blogdata.GalleryModels, blogdata.ImageModels, blogdata.TextModels, blogdata.VideoModels);

                    if (deletetempService.GetCurrentBlogId() == id && deletetempService.Retrieve() != null && deletetempService.Retrieve().Count >= 0)
                    {
                        elements = deletetempService.Retrieve();
                    }
                    else
                    {
                        elements = elements.OrderBy(x => x.position).ToList();
                        deletetempService.Clear();
                        deletetempService.Initialize(elements);
                        deletetempService.SetCurrentBlogId(id.GetValueOrDefault());
                    }



                    var viewmodel = new ExternBlogViewModel {
                        Title = blogdata.Title, Subtitle = blogdata.Subtitle, Elements = elements
                    };


                    return(View(viewmodel));
                }
            }

            return(RedirectToAction("Overview", "Blog"));
        }