示例#1
0
        // Saves a new blog group.  Any exceptions are propagated up to the caller.
        void SaveNewGroup()
        {
            int displayOrder;

            if (!Int32.TryParse(txtDisplayOrder.Text, out displayOrder))
            {
                displayOrder = NullValue.NullInt32;
            }

            var blogGroup = new BlogGroup
            {
                Title        = txtTitle.Text,
                Description  = txtDescription.Text,
                IsActive     = true,
                DisplayOrder = displayOrder,
            };

            if (ObjectProvider.Instance().InsertBlogGroup(blogGroup) > 0)
            {
                messagePanel.ShowMessage(Resources.GroupsEditor_BlogGroupCreated);
            }
            else
            {
                messagePanel.ShowError(Resources.Message_UnexpectedError);
            }
        }
示例#2
0
        // Saves changes to a blog group.  Any exceptions are propagated up to the caller.
        void SaveGroupEdits()
        {
            int displayOrder;

            if (!Int32.TryParse(txtDisplayOrder.Text, out displayOrder))
            {
                displayOrder = NullValue.NullInt32;
            }

            var blogGroup = new BlogGroup
            {
                Id           = GroupId,
                Title        = txtTitle.Text,
                Description  = txtDescription.Text,
                IsActive     = Convert.ToBoolean(hfActive.Value),
                DisplayOrder = displayOrder,
            };


            if (ObjectProvider.Instance().UpdateBlogGroup(blogGroup))
            {
                messagePanel.ShowMessage(Resources.GroupsEditor_BlogGroupSaved);
            }
            else
            {
                messagePanel.ShowError(Resources.Message_UnexpectedError);
            }
        }
 /// <summary>
 /// Inserts the blog group.
 /// </summary>
 /// <param name="blogGroup">The group to insert.</param>
 /// <returns>The blog group id</returns>
 public override int InsertBlogGroup(BlogGroup blogGroup)
 {
     return(_procedures.InsertBlogGroup(blogGroup.Title,
                                        blogGroup.IsActive,
                                        blogGroup.DisplayOrder.NullIfMinValue(),
                                        blogGroup.Description.NullIfEmpty()));
 }
示例#4
0
        public ActionResult Create(BlogGroup blogGroup, HttpPostedFileBase fileUpload)
        {
            if (ModelState.IsValid)
            {
                #region Upload and resize image if needed
                string newFilenameUrl = string.Empty;
                if (fileUpload != null)
                {
                    string filename    = Path.GetFileName(fileUpload.FileName);
                    string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                         + Path.GetExtension(filename);

                    newFilenameUrl = "/Uploads/blog/" + newFilename;
                    string physicalFilename = Server.MapPath(newFilenameUrl);

                    fileUpload.SaveAs(physicalFilename);

                    blogGroup.ImageUrl = newFilenameUrl;
                }
                #endregion
                blogGroup.IsDeleted    = false;
                blogGroup.CreationDate = DateTime.Now;
                blogGroup.Id           = Guid.NewGuid();
                db.BlogGroups.Add(blogGroup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(blogGroup));
        }
示例#5
0
        public ActionResult Details(string groupUrlParam, string blogUrlParam)
        {
            BlogGroup blogGroup = db.BlogGroups.Where(current => current.UrlParam == groupUrlParam && current.IsDeleted == false && current.IsActive == true).FirstOrDefault();

            if (blogGroup == null)
            {
                return(HttpNotFound());
            }
            Blog blog = db.Blogs.Where(current => current.UrlParam == blogUrlParam && current.IsActive == true && current.IsDeleted == false).FirstOrDefault();

            if (blog == null)
            {
                return(HttpNotFound());
            }
            BlogDetailViewModel blogDetailViewModel = new BlogDetailViewModel()
            {
                BlogGroup    = blogGroup,
                Blog         = blog,
                Categories   = db.BlogGroups.Where(current => current.Id != blogGroup.Id && current.IsActive == true && current.IsDeleted == false).ToList(),
                RecentBlogs  = db.Blogs.Where(current => current.Id != blog.Id && current.IsActive == true && current.IsDeleted == false).OrderByDescending(current => current.CreationDate).Take(5).ToList(),
                RelatedBlogs = db.Blogs.Where(current => current.BlogGroupId == blogGroup.Id && current.Id != blog.Id && current.IsActive == true && current.IsDeleted == false).Take(2).ToList(),
                BlogComments = db.BlogComments.Where(current => current.BlogId == blog.Id && current.IsActive == true && current.IsDeleted == false).ToList()
            };

            return(View(blogDetailViewModel));
        }
示例#6
0
        public async Task <IActionResult> AddBlogGroup(string userId, BlogGroupForCreateUpdateDto blogGroupForCreateDto)
        {
            var blogGroupFromRepo = await _db.BlogGroupRepository
                                    .GetAsync(p => p.Name == blogGroupForCreateDto.Name);

            if (blogGroupFromRepo == null)
            {
                var cardForCreate = new BlogGroup();
                var blogGroup     = _mapper.Map(blogGroupForCreateDto, cardForCreate);

                await _db.BlogGroupRepository.InsertAsync(blogGroup);

                if (await _db.SaveAsync())
                {
                    var blogGroupForReturn = _mapper.Map <BlogGroupForReturnDto>(blogGroup);

                    return(CreatedAtRoute("GetBlogGroup", new { v = HttpContext.GetRequestedApiVersion().ToString(), id = blogGroup.Id, userId = userId }, blogGroupForReturn));
                }
                else
                {
                    return(BadRequest("خطا در ثبت اطلاعات"));
                }
            }
            {
                return(BadRequest("این دسته بلاگ قبلا ثبت شده است"));
            }
        }
示例#7
0
        public Task <IList <BlogItem> > LoadItemsAsync(BlogGroup group)
        {
            return(Task.Run(async() =>
            {
                var feed = await GetFeed(group.RssUri);

                IList <BlogItem> items = new List <BlogItem>();

                foreach (var item in feed.Items)
                {
                    try
                    {
                        var blogItem = new BlogItem {
                            Group = group
                        };
                        var uri = string.Empty;

                        if (item.Links.Count > 0)
                        {
                            var link =
                                item.Links.FirstOrDefault(
                                    l => l.RelationshipType.Equals("alternate", StringComparison.OrdinalIgnoreCase)) ??
                                item.Links[0];
                            uri = link.Uri.AbsoluteUri;
                        }

                        blogItem.Id = uri;

                        blogItem.PageUri = new Uri(uri, UriKind.Absolute);
                        blogItem.Title = item.Title != null ? item.Title.Text : "(no title)";

                        blogItem.PostDate = item.PublishDate.LocalDateTime;

                        var content = "(no content)";

                        if (item.Content != null)
                        {
                            content = BlogUtility.ParseHtml(((TextSyndicationContent)item.Content).Text);
                        }
                        else if (item.Summary != null)
                        {
                            content = BlogUtility.ParseHtml(item.Summary.Text);
                        }

                        blogItem.Description = content;

                        items.Add(blogItem);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                return items;
            }));
        }
示例#8
0
 /// <summary>
 /// Inserts the blog group.
 /// </summary>
 /// <param name="blogGroup">The group to insert.</param>
 /// <returns>The blog group id</returns>
 public override bool UpdateBlogGroup(BlogGroup blogGroup)
 {
     return(_procedures.UpdateBlogGroup(
                id: blogGroup.Id,
                title: blogGroup.Title,
                active: blogGroup.IsActive,
                description: blogGroup.Description.NullIfEmpty(),
                displayOrder: blogGroup.DisplayOrder.NullIfMinValue()));
 }
示例#9
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            BlogGroup blogGroup = db.BlogGroups.Find(id);

            blogGroup.IsDeleted    = true;
            blogGroup.DeletionDate = DateTime.Now;

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void GivenValidGroupIdWhenRequestedThenShouldReturnGroup()
        {
            var expected = new BlogGroup {
                Id = Guid.NewGuid().ToString()
            };

            _target.GroupList.Add(expected);
            var actual = _target.GetGroup(expected.Id);

            Assert.AreSame(expected, actual, "Test failed: actual group does not match expected.");
        }
        static void countPosts(BlogContext bc)
        {
            var query = from post in bc.Posts
                        group post by post.BlogId into BlogGroup
                        select new { BlogID = BlogGroup.Key, PostCount = BlogGroup.Count() };

            foreach (var b in query)
            {
                Console.WriteLine("BlogID: {0} PostCount: {1}", b.BlogID, b.PostCount);
            }
        }
示例#12
0
        // GET: BlogGroups/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlogGroup blogGroup = db.BlogGroups.Find(id);

            if (blogGroup == null)
            {
                return(HttpNotFound());
            }
            return(View(blogGroup));
        }
示例#13
0
        public ActionResult List(string param)
        {
            BlogGroup blogGroup = db.BlogGroups.Where(current => current.UrlParam == param).FirstOrDefault();

            BlogListViewModel viewModel = new BlogListViewModel();

            viewModel.BaseInfo  = menu.ReturnMenu();
            viewModel.BlogGroup = blogGroup;
            viewModel.Blogs     = db.Blogs.Where(current => current.BlogGroupId == blogGroup.Id).OrderByDescending(current => current.CreationDate).ToList();

            ViewBag.PageId = "blog-grid-full-width";

            return(View(viewModel));
        }
示例#14
0
        public ActionResult List(string urlParam)
        {
            BlogListViewModel blogList = new BlogListViewModel()
            {
                MenuProductGroups = baseViewModel.GetMenu(),
                MenuServiceGroups = baseViewModel.GetMenuServices(),
                FooterRecentBlog  = baseViewModel.GetFooterRecentBlog()
            };

            if (urlParam.ToLower() == "all")
            {
                blogList.Blogs = db.Blogs.Include(b => b.BlogGroup).Where(b => b.IsDeleted == false && b.IsActive)
                                 .OrderByDescending(b => b.CreationDate).ToList();

                blogList.BlogGroupTitle = "مطالب وبلاگ";

                ViewBag.Title       = "وبلاگ";
                ViewBag.Description =
                    "در این بخش از وب سایت رسمی دکتر کامران صحت می توانید جدیدترین مقالات در حوزه های مختلف را مطالعه نمایید.";

                blogList.BlogGroupSummery =
                    "در این بخش از وب سایت رسمی دکتر کامران صحت می توانید جدیدترین مقالات در حوزه های مختلف را مطالعه نمایید.";
            }
            else
            {
                BlogGroup blogGroup = db.BlogGroups.FirstOrDefault(current =>
                                                                   current.UrlParam == urlParam && current.IsDeleted == false && current.IsActive);

                if (blogGroup != null)
                {
                    blogList.Blogs = db.Blogs.Include(b => b.BlogGroup)
                                     .Where(b => b.IsDeleted == false && b.IsActive && b.BlogGroupId == blogGroup.Id)
                                     .OrderByDescending(b => b.CreationDate).ToList();

                    ViewBag.Title       = blogGroup.Title;
                    ViewBag.Description = blogGroup.Summery;

                    blogList.BlogGroupTitle   = blogGroup.Title;
                    blogList.UrlParam         = blogGroup.UrlParam;
                    blogList.BlogGroupSummery = blogGroup.Summery;
                    blogList.FooterRecentBlog = baseViewModel.GetFooterRecentBlog();
                }
                else
                {
                    return(RedirectToAction("List", new { urlParam = "all" }));
                }
            }
            return(View(blogList));
        }
        public void GivenValidItemIdWhenRequestedThenShouldReturnItem()
        {
            var expected = new BlogItem {
                Id = Guid.NewGuid().ToString()
            };
            var group = new BlogGroup {
                Id = Guid.NewGuid().ToString()
            };

            group.Items.Add(expected);
            _target.GroupList.Add(group);
            var actual = _target.GetItem(expected.Id);

            Assert.AreSame(expected, actual, "Test failed: actual item does not match expected.");
        }
示例#16
0
        public ActionResult List(string blogGroupUrlParam)
        {
            BlogGroup blogGroup = db.BlogGroups.Where(current => current.UrlParam == blogGroupUrlParam && current.IsActive == true && current.IsDeleted == false).FirstOrDefault();

            if (blogGroup == null)
            {
                return(HttpNotFound());
            }
            BlogGroupViewModel blogGroupViewModel = new BlogGroupViewModel()
            {
                BlogGroup = blogGroup,
                Blogs     = db.Blogs.Where(current => current.BlogGroupId == blogGroup.Id && current.IsActive == true && current.IsDeleted == false).ToList()
            };

            return(View(blogGroupViewModel));
        }
示例#17
0
        public async Task <IList <BlogGroup> > LoadBlogsAsync()
        {
            var retVal = new List <BlogGroup>();
            var info   = NetworkInformation.GetInternetConnectionProfile();

            if (info == null || info.GetNetworkConnectivityLevel() != NetworkConnectivityLevel.InternetAccess)
            {
                return(retVal);
            }

            var content = await PathIO.ReadTextAsync("ms-appx:///Assets/Blogs.js");

            content = content.Trim(Utf8ByteOrderMark.ToCharArray());
            var blogs = JsonArray.Parse(content);

            foreach (JsonValue item in blogs)
            {
                var error = string.Empty;
                try
                {
                    var uri   = item.GetObject()["BlogUri"].GetString();
                    var group = new BlogGroup
                    {
                        Id     = uri,
                        RssUri = new Uri(uri, UriKind.Absolute)
                    };

                    var client = GetSyndicationClient();
                    var feed   = await client.RetrieveFeedAsync(group.RssUri);

                    group.Title = feed.Title.Text;

                    retVal.Add(group);
                }
                catch (Exception ex)
                {
                    error = ex.Message;
                }

                if (!string.IsNullOrEmpty(error))
                {
                    await _dialog.ShowDialogAsync(error);
                }
            }

            return(retVal);
        }
示例#18
0
        public ActionResult List(string urlParam)
        {
            BlogListViewModel blogListViewModel = new BlogListViewModel();

            BlogGroup blogGroup = db.BlogGroups.FirstOrDefault(current => current.UrlParam == urlParam);

            if (blogGroup == null)
            {
                return(RedirectPermanent("/"));
            }
            blogListViewModel.Menu                  = menu.ReturnMenuTours();
            blogListViewModel.Footer                = menu.ReturnFooter();
            blogListViewModel.MenuBlogGroups        = menu.ReturnBlogGroups();
            blogListViewModel.BlogGroup             = blogGroup;
            blogListViewModel.Blogs                 = db.Blogs.Where(current => current.IsDelete == false && current.BlogGroupId == blogGroup.Id).ToList();
            blogListViewModel.SidebarTourCategories = GetSideBarTourCategory();

            ViewBag.Title       = blogGroup.PageTitle;
            ViewBag.Description = blogGroup.PageDescription;

            ViewBag.header = "/Images/header1.jpg";
            //ViewBag.header = "/Images/headers/guid.jpg";

            if (urlParam == "online-mag")
            {
                ViewBag.header = "/images/headers/online-mag.jpg";
            }

            else if (urlParam == "food-tour")
            {
                ViewBag.header = "/images/headers/restourant.jpg";
            }

            else if (urlParam == "travel-guide")
            {
                ViewBag.header = "/images/headers/guid.jpg";
            }

            else if (urlParam == "tourist-attractions")
            {
                ViewBag.header = "/images/headers/attractions.jpg";
            }

            return(View(blogListViewModel));
        }
        public ActionResult Edit(BlogGroup blogGroup, HttpPostedFileBase fileUpload, HttpPostedFileBase coverUpload)
        {
            if (ModelState.IsValid)
            {
                #region Upload and resize image if needed
                string newFilenameUrl = blogGroup.ImageUrl;
                if (fileUpload != null)
                {
                    string filename    = Path.GetFileName(fileUpload.FileName);
                    string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                         + Path.GetExtension(filename);

                    newFilenameUrl = "/Uploads/Blog/" + newFilename;
                    string physicalFilename = Server.MapPath(newFilenameUrl);

                    fileUpload.SaveAs(physicalFilename);

                    blogGroup.ImageUrl = newFilenameUrl;
                }
                #endregion
                #region Upload and resize cover if needed
                string newCoverFilenameUrl = blogGroup.CoverImage;
                if (coverUpload != null)
                {
                    string covername        = Path.GetFileName(coverUpload.FileName);
                    string newCoverFilename = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                              + Path.GetExtension(covername);

                    newCoverFilenameUrl = "/Uploads/Blog/" + newCoverFilename;
                    string physicalCovername = Server.MapPath(newCoverFilenameUrl);

                    coverUpload.SaveAs(physicalCovername);

                    blogGroup.CoverImage = newCoverFilenameUrl;
                }
                #endregion
                blogGroup.IsDelete        = false;
                db.Entry(blogGroup).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(blogGroup));
        }
示例#20
0
        void BindEdit()
        {
            pnlResults.Visible = false;
            pnlEdit.Visible    = true;

            BindEditHelp();

            if (!CreatingGroup)
            {
                BlogGroup group = ObjectProvider.Instance().GetBlogGroup(GroupId, false);
                if (group != null)
                {
                    txtTitle.Text        = group.Title;
                    txtDescription.Text  = group.Description;
                    txtDisplayOrder.Text = group.DisplayOrder.ToString(CultureInfo.InvariantCulture);
                    hfActive.Value       = group.IsActive.ToString(CultureInfo.CurrentCulture);
                }
            }
        }
 protected void btnSaveGroup_OnClick(object sender, EventArgs e)
 {
     if (ViewState["ID"] == null)
     {
         Models.BlogGroup newsGroup = new BlogGroup()
         {
             TitleGroup = txtNameGroup.Text,
         };
         db.BlogGroups.Add(newsGroup);
         db.SaveChanges();
         Response.Redirect(Request.UrlReferrer.AbsolutePath.ToString());
     }
     else
     {
         int groupid     = int.Parse(ViewState["ID"].ToString());
         var newsGroupid = db.BlogGroups.First(p => p.NewsGroupID == groupid);
         newsGroupid.TitleGroup = txtNameGroup.Text;
         db.SaveChanges();
         Response.Redirect(Request.UrlReferrer.AbsolutePath.ToString());
     }
 }
示例#22
0
        public Task <IList <BlogGroup> > LoadBlogsAsync()
        {
            return(Task.Run(async() =>
            {
                IList <BlogGroup> blogs = new List <BlogGroup>();
// ReSharper disable LoopCanBeConvertedToQuery
                foreach (var blog in GroupsList)
// ReSharper restore LoopCanBeConvertedToQuery
                {
                    var feed = await GetFeed(blog);
                    var blogEntry = new BlogGroup
                    {
                        Id = blog.ToString(),
                        RssUri = blog,
                        Title = feed.Title.Text
                    };
                    blogs.Add(blogEntry);
                }
                return blogs;
            }));
        }
示例#23
0
        void ToggleActive()
        {
            try
            {
                BlogGroup group     = Config.GetBlogGroup(GroupId, false);
                var       blogGroup = new BlogGroup
                {
                    Id           = GroupId,
                    Title        = txtTitle.Text,
                    Description  = txtDescription.Text,
                    IsActive     = !IsActive,
                    DisplayOrder = group.DisplayOrder,
                };

                ObjectProvider.Instance().UpdateBlogGroup(blogGroup);
            }
            catch (BaseBlogConfigurationException e)
            {
                messagePanel.ShowError(e.Message);
            }

            BindList();
        }
示例#24
0
        public ActionResult Edit(BlogGroup blogGroup, HttpPostedFileBase fileUpload)
        {
            if (ModelState.IsValid)
            {
                if (!CheckUrlParam(blogGroup.UrlParam, blogGroup.Id))
                {
                    #region Upload and resize image if needed
                    string newFilenameUrl = blogGroup.ImageUrl;
                    if (fileUpload != null)
                    {
                        string filename    = Path.GetFileName(fileUpload.FileName);
                        string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                             + Path.GetExtension(filename);

                        newFilenameUrl = "/Uploads/blog/" + newFilename;
                        string physicalFilename = Server.MapPath(newFilenameUrl);

                        fileUpload.SaveAs(physicalFilename);

                        blogGroup.ImageUrl = newFilenameUrl;
                    }
                    #endregion
                    blogGroup.IsDeleted       = false;
                    db.Entry(blogGroup).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["DupliacteParam"] = "پارامتر Url تکراری است";
                    ViewBag.id = blogGroup.Id;
                    return(View(blogGroup));
                }
            }
            return(View(blogGroup));
        }
示例#25
0
 /// <summary>
 /// Inserts the blog group.
 /// </summary>
 /// <param name="blogGroup">The group to insert.</param>
 /// <returns>The blog group id</returns>
 public abstract int InsertBlogGroup(BlogGroup blogGroup);
 public Task <IList <BlogItem> > LoadItemsAsync(BlogGroup group)
 {
     return(Task.Run(() => ((IList <BlogItem>)BlogItems)));
 }
示例#27
0
        public ActionResult Details(string param)
        {
            //List<ServiceGroup> servicegroup = db.ServiceGroups.Where(current => current.AverageRate == null).ToList();
            //foreach(ServiceGroup service in servicegroup)
            //{
            //    service.AverageRate = 5;

            //}
            //List<Service> services = db.Services.Where(current => current.AverageRate == null).ToList();
            //foreach (Service ser in services)
            //{
            //    ser.AverageRate = 5;

            //}
            //db.SaveChanges();
            //List<Blog> blogs = db.Blogs.Where(current => current.IsDeleted == false).ToList();
            //foreach(var item in blogs)
            //{
            //    item.AverageRate = 5;
            //}
            //db.SaveChanges();
            if (param == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Blog      blog      = db.Blogs.Where(current => current.UrlParam.ToLower() == param.ToLower() && current.IsDeleted == false).FirstOrDefault();
            BlogGroup blogGroup = db.BlogGroups.Where(current => current.Id == blog.BlogGroupId).FirstOrDefault();

            if (blog == null)
            {
                return(HttpNotFound());
            }

            int visitNum = blog.Visit;

            blog.Visit = visitNum + 1;
            db.SaveChanges();
            User writter = db.Users.Find(blog.WritterId);

            BlogDetailViewModel blogDetail = new BlogDetailViewModel();

            blogDetail.Menu        = menuHelper.ReturnMenu();
            blogDetail.Rate        = blog.AverageRate.Value.ToString().Replace('/', '.');
            blogDetail.FooterLink  = menuHelper.GetFooterLink();
            blogDetail.Username    = menuHelper.ReturnUsername();
            blogDetail.Blog        = blog;
            blogDetail.RecentBlogs = db.Blogs.Where(current => current.IsDeleted == false && current.IsActive == true).OrderByDescending(current => current.CreationDate).Take(5).ToList();
            blogDetail.BlogGroups  = ReturnBlogGroupCount();
            blogDetail.Comments    = ReturnComments(blog.Id);
            ViewBag.Title          = blog.PageTitle;
            ViewBag.Description    = blog.PageDescription;
            ViewBag.param          = param;
            ViewBag.Canonical      = "https://www.rushweb.ir/blog/" + blog.UrlParam;
            ViewBag.rate           = blog.AverageRate.Value.ToString().Replace('/', '.');
            int rateCount = db.Rates.Where(current => current.EntityId == blog.Id).Count();

            if (rateCount > 0)
            {
                ViewBag.RatingCount = rateCount;
            }
            else
            {
                ViewBag.RatingCount = 1;
            }
            ViewBag.image = "https://www.rushweb.ir" + blog.ImageUrl;
            if (blogGroup.UrlParam.ToLower() == "reportage-agahi-news")
            {
                ViewBag.Canonical = "https://www.rushweb.ir/reportage";
                return(RedirectPermanent("https://www.rushweb.ir/reportage"));
            }
            else
            {
                ViewBag.Canonical = "https://www.rushweb.ir/blog/" + param;
            }

            ViewBag.creationDate = blog.CreationDate.ToString(CultureInfo.InvariantCulture);

            if (!string.IsNullOrEmpty(blog.LastModifiedDate.ToString()))
            {
                ViewBag.ModifiedDate = blog.LastModifiedDate.Value.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                ViewBag.ModifiedDate = blog.CreationDate.ToString(CultureInfo.InvariantCulture);
            }


            if (writter != null)
            {
                blogDetail.Writter   = writter.FullName;
                blogDetail.WritterId = writter.Id.ToString();
                ViewBag.Auther       = writter.FullName;
            }

            else
            {
                blogDetail.Writter   = "rushweb";
                ViewBag.Auther       = "rushweb";
                blogDetail.WritterId = null;
            }



            return(View(blogDetail));
        }
示例#28
0
        public async Task <IList <BlogItem> > LoadItemsAsync(BlogGroup group)
        {
            var info = NetworkInformation.GetInternetConnectionProfile();

            if (info == null || info.GetNetworkConnectivityLevel() != NetworkConnectivityLevel.InternetAccess)
            {
                return(new List <BlogItem>());
            }

            var retVal     = new List <BlogItem>();
            var outerError = string.Empty;

            try
            {
                var client = GetSyndicationClient();
                var feed   = await client.RetrieveFeedAsync(group.RssUri);

                foreach (var item in feed.Items.OrderBy(i => i.PublishedDate))
                {
                    var error = string.Empty;
                    try
                    {
                        var blogItem = new BlogItem {
                            Group = group
                        };
                        var uri = string.Empty;

                        if (item.Links.Count > 0)
                        {
                            var link =
                                item.Links.FirstOrDefault(
                                    l => l.Relationship.Equals("alternate", StringComparison.OrdinalIgnoreCase)) ??
                                item.Links[0];
                            uri = link.Uri.AbsoluteUri;
                        }

                        blogItem.Id = uri;

                        blogItem.PageUri = new Uri(uri, UriKind.Absolute);
                        blogItem.Title   = item.Title != null ? item.Title.Text : "(no title)";

                        blogItem.PostDate = item.PublishedDate.LocalDateTime;

                        var content = "(no content)";

                        if (item.Content != null)
                        {
                            content = BlogUtility.ParseHtml(item.Content.Text);
                        }
                        else if (item.Summary != null)
                        {
                            content = BlogUtility.ParseHtml(item.Summary.Text);
                        }

                        blogItem.Description = content;

                        retVal.Add(blogItem);
                    }
                    catch (Exception ex)
                    {
                        error = ex.Message;
                    }

                    if (!string.IsNullOrEmpty(error))
                    {
                        await _dialog.ShowDialogAsync(error);
                    }
                }
            }
            catch (Exception ex)
            {
                outerError = ex.Message;
            }

            if (!string.IsNullOrEmpty(outerError))
            {
                await _dialog.ShowDialogAsync(outerError);
            }
            return(retVal);
        }
        public void CanSetAndGetSimpleProperties()
        {
            var group = new BlogGroup();

            UnitTestHelper.AssertSimpleProperties(group);
        }
示例#30
0
 /// <summary>
 /// Update the blog group.
 /// </summary>
 /// <param name="blogGroup">The group to insert.</param>
 /// <returns>The blog group id</returns>
 public abstract bool UpdateBlogGroup(BlogGroup blogGroup);