コード例 #1
0
ファイル: IndexController.cs プロジェクト: Wysnan/personal
 //
 // GET: /Index/
 public ActionResult Index()
 {
     BlogModel blogModel = new BlogModel();
     var blogs= blogModel.List().Take(4).OrderByDescending(a => a.CreateTime).ToList();
     ViewBag.Blogs = blogs;
     return View();
 }
コード例 #2
0
ファイル: BlogController.cs プロジェクト: eCollobro/eCollabro
 public ActionResult Blog(int Id = 0)
 {
     BlogModel blogModel = new BlogModel();
     blogModel.BlogId = Id;
     if (Request.IsAjaxRequest())
         return PartialView(blogModel);
     else
         return View(blogModel);
 }
コード例 #3
0
        public JsonResult WriteBlog(BlogModel bModel)
        {
            bModel.TimeStamp = DateTime.UtcNow;
            var    bTable = Mapper.Map <BlogTable>(bModel);
            string userId = User.Identity.GetUserId();

            var result = _changeService.WriteBlog(bTable, userId);

            return(Json(result));
        }
コード例 #4
0
ファイル: SettingsHelpers.cs プロジェクト: jarmatys/CMS
        public static BlogModel MergeViewWithModelBlog(BlogModel model, BlogView view)
        {
            model.CommentsNotify = view.CommentsNotify;
            model.PostPerPage    = view.PostPerPage;
            model.AllowComments  = view.AllowComments;
            model.DateFormat     = view.DateFormat;
            model.TimeFormat     = view.TimeFormat;

            return(model);
        }
コード例 #5
0
        public IActionResult WriteBlog(BlogModel model)
        {
            var name     = model.BodyText;
            var selected = model.selected;
            var ss       = model._section;
            var mmm      = model.selected;

            ViewBag.ListItems = ss;
            return(View());
        }
コード例 #6
0
        public IActionResult WriteBlog()
        {
            BlogModel x = new BlogModel();

            x._section = _Context.Sections.Where(p => p.ActiveZero == false).ToList();



            return(View(x));
        }
コード例 #7
0
        private async Task OnSelectedBookMark(BlogModel data)
        {
            bool response = await App.Current.MainPage.DisplayAlert("ยืนยัน", "คุณต้องการยกเลิกรายการโปรด \n ใช่ หรือ ไม่", "ใช่", "ไม่ใช่");

            if (response)
            {
                UnFavorite(data);
            }
            //await App.Current.MainPage.Navigation.PushAsync(new FollowPage());
        }
コード例 #8
0
ファイル: BlogController.cs プロジェクト: Gyoung/BlogProject
 //
 // GET: /Blog/
 public ActionResult Add(int?id)
 {
     ViewData["blogSort"] = BlogModel.GetBlogSorts();
     if (LoginHelper.IsEditMode && id.HasValue)
     {
         Blog blog = BlogModel.GetBlog(id.Value);
         return(View(blog));
     }
     return(View());
 }
コード例 #9
0
ファイル: BlogDAL.cs プロジェクト: doubihaozi/Blog
 /// <summary>
 /// 添加一条博客
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(BlogModel model)
 {
     ///打开数据库进行操作.
     using (var conn = ConnectionFactory.GetOpenconnection(ConnStr))
     {
         string sql = string.Format(@"insert into Blog(Title,Body,Body_md,CBh,CName,Remark,Sort) values(@Title,@Body,@Body_md,@CBh,@CName,@Remark,@Sort);select @@IDENTITY");
         int    Id  = conn.Query <int>(sql, model).FirstOrDefault();
         return(Id);
     }
 }
コード例 #10
0
ファイル: BlogDAL.cs プロジェクト: doubihaozi/Blog
 /// <summary>
 /// 修改博客内容或标题
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(BlogModel model)
 {
     using (var conn = ConnectionFactory.GetOpenconnection(ConnStr))
     {
         string sql = string.Format(@"update Blog set Title=@Title,Body=@Body,CName=@CName,CBh=@CBh 
                                     where Bid=@Bid");
         int    res = conn.Execute(sql, model);
         return(res);
     }
 }
コード例 #11
0
        public Blog Post(BlogModel blog)
        {
            blog.Id          = Guid.NewGuid();
            blog.ThoiGianTao = DateTime.Now;
            var data = blog.CopyAs <Blog>();

            _context.Blog.Add(data);
            _context.SaveChanges();
            return(data);
        }
コード例 #12
0
        public IActionResult Detail(int?id)
        {
            BlogModel blogFromDb = new BlogModel();
            UserModel user       = new UserModel();

            blogFromDb = _unitOfWork.Blog.Get(id.GetValueOrDefault());
            id         = blogFromDb.UserId;
            user       = _unitOfWork.User.Get(id.GetValueOrDefault());
            return(View(Tuple.Create(blogFromDb, user)));
        }
コード例 #13
0
 public static string DeclineComment(string id)
 {
     if (id != "")
     {
         int       commentid = Convert.ToInt32(id);
         BlogModel objBlog   = new BlogModel();
         objBlog.CommentDecline(commentid);
     }
     return("Comment Decline Succesfully");
 }
コード例 #14
0
 private void OnSelectedBookMark(BlogModel data)
 {
     if (data.IsOn)
     {
         UnFavorite(data);
     }
     else
     {
         Favorite(data);
     }
 }
コード例 #15
0
ファイル: BlogController.cs プロジェクト: danruziska/70-486
        // GET: Blog
        public ActionResult Index()
        {
            /*
             * Exemplo de modelo de domínio
             * Nessa abordagem, a model representa diretamente o dado que foi buscado (uma lista de objetos do tipo Blog)
             */
            BlogModel model = new BlogModel();
            var       blogs = model.GetBlogs();

            return(View(blogs));
        }
コード例 #16
0
ファイル: BlogRepository.cs プロジェクト: shuxinqin/AceBlog
        public BlogNeighbour GetNeighbours(int id, int authorId)
        {
            BlogNeighbour ret = new BlogNeighbour();

            var q = this.Query().Where(a => a.AuthorId == authorId && a.Status == BlogStatus.Published);

            ret.Prev = BlogModel.Create(q.Where(a => a.Id < id).OrderByDesc(a => a.Id).FirstOrDefault());
            ret.Next = BlogModel.Create(q.Where(a => a.Id > id).OrderBy(a => a.Id).FirstOrDefault());

            return(ret);
        }
コード例 #17
0
        protected void RepeaterCategories_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            try
            {
                lblMessage.Visible = false;
                lblMessage.Text    = "";

                if (e.CommandName == "GetCategoriesById")
                {
                    int       id           = Convert.ToInt32(e.CommandArgument);
                    BlogModel objblogModel = new BlogModel();
                    var       results      = objblogModel.getBlog(id);
                    if (results.Count() == 0)
                    {
                        lblMessage.Visible = true;
                        lblMessage.Text    = "No Item to Dispaly";
                    }

                    int PageIndex          = 0;
                    int PageSize           = 3;
                    int skip               = PageIndex * PageSize;
                    int PageCount          = Convert.ToInt32(Convert.ToDouble(Math.Ceiling((double)((double)results.Count() / (double)PageSize))));
                    List <BlogModel> query = results.Skip(skip).Take(PageSize).ToList();
                    BlogRepeater.DataSource = query;
                    BlogRepeater.DataBind();
                    List <PageModel> paging = new List <PageModel>();
                    Boolean          active = false;
                    for (int i = 0; i < PageCount; i++)
                    {
                        if (i == 0)
                        {
                            active = true;
                        }
                        else
                        {
                            active = false;
                        }
                        paging.Add(new PageModel
                        {
                            pageindex  = i,
                            pagename   = i + 1,
                            pageactive = active,
                        });
                    }
                    Repeater1.DataSource = paging;
                    Repeater1.DataBind();
                    SearchPaging.Value = Convert.ToString(id);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(" + ex.Message + ")", true);
            }
        }
コード例 #18
0
        public ActionResult Get(string id)
        {
            //string id = Request.Params["name"].ToString();
            Blog      b    = new Blog(this.db);
            BlogModel blog = b.GetBlog(id);

            ViewBag.Blog = blog;
            ViewBag.Page = "Victor Sawal";
            this.PageViewLog(Request);
            return(View("Index"));
        }
コード例 #19
0
        public async Task <IActionResult> Edit(BlogModel model)
        {
            Blog blog = _database.Blogs.FirstOrDefault(b => b.Id == model.Id);

            blog.Name        = model.Name;
            blog.Description = model.Description;
            //_database.Blogs.Update(blog);
            await _database.SaveChangesAsync();

            return(RedirectToAction("Details", "Blog", new { id = blog.Id }));
        }
コード例 #20
0
        public ActionResult GetMyBlog(int id)
        {
            BlogModel blog = this.Service.GetBlogDetail(id);

            if (blog != null && blog.AuthorId != this.CurrentSession.UserId)
            {
                blog = null;
            }

            return(this.SuccessData(blog));
        }
コード例 #21
0
        public static string ApproveComments(string id)
        {
            if (id != "")
            {
                int       commentid = Convert.ToInt32(id);
                BlogModel objBlog   = new BlogModel();
                objBlog.CommentApproved(commentid);
            }

            return("Comment Approve Succesfully");
        }
コード例 #22
0
ファイル: BlogController.cs プロジェクト: sandeep18051989/SMS
        public ActionResult Edit(BlogModel model, FormCollection frm, bool continueEditing)
        {
            if (!_permissionService.Authorize("ManageBlogs"))
            {
                return(AccessDeniedView());
            }

            var user            = _userContext.CurrentUser;
            var newBlogPictures = new List <BlogPicture>();
            // Check for duplicate blog, if any
            var _blog = _blogService.GetBlogByName(model.Name);

            if (_blog != null && _blog.Id != model.Id)
            {
                ModelState.AddModelError("Name", "An Blog with the same name already exists. Please choose a different name.");
            }

            if (ModelState.IsValid)
            {
                var blogItem = _blogService.GetBlogById(model.Id);

                if (blogItem == null || blogItem.IsDeleted)
                {
                    return(RedirectToAction("List"));
                }

                blogItem            = model.ToEntity(blogItem);
                blogItem.ModifiedOn = DateTime.Now;
                blogItem.UserId     = user.Id;
                _blogService.Update(blogItem);

                // Save URL Record
                model.SystemName = blogItem.ValidateSystemName(model.SystemName, model.Name, true);
                _urlService.SaveSlug(blogItem, model.SystemName);
            }
            else
            {
                model.AvailableAcadmicYears = _smsService.GetAllAcadmicYears().Select(x => new SelectListItem()
                {
                    Text     = x.Name.Trim(),
                    Value    = x.Id.ToString(),
                    Selected = x.IsActive
                }).ToList();
                ErrorNotification("An error occured while updating blog. Please try again.");
                return(View(model));
            }

            SuccessNotification("Blog updated successfully.");
            if (continueEditing)
            {
                return(RedirectToAction("Edit", new { id = model.Id }));
            }
            return(RedirectToAction("List"));
        }
コード例 #23
0
        public IActionResult About()
        {
            ViewData["Message"] = "Your application description page.";

            var model = new BlogModel()
            {
                Blog = Blog
            };

            return(View(model));
        }
コード例 #24
0
 public IViewComponentResult Invoke(BlogModel model)
 {
     if (model == null)
     {
         return(View());
     }
     else
     {
         return(View(model));
     }
 }
コード例 #25
0
        public IActionResult Contact()
        {
            ViewData["Message"] = "Your contact page.";

            var model = new BlogModel()
            {
                Blog = Blog
            };

            return(View(model));
        }
コード例 #26
0
        public BlogModel DeletePost(int Id)
        {
            BlogModel post = context.Blog.Find(Id);

            if (post != null)
            {
                context.Blog.Remove(post);
                context.SaveChanges();
            }
            return(post);
        }
コード例 #27
0
ファイル: HomeController.cs プロジェクト: doubihaozi/Blog
        public IActionResult Add(int?Id)
        {
            ViewBag.CategoryList = CategoryDAL.CategoryList();
            BlogModel model = new BlogModel();

            if (Id != null)
            {
                model = BlogDAL.GetBlogModel(Id.Value);
            }
            return(View(model));
        }
コード例 #28
0
        public async Task <IActionResult> Create(BlogModel model)
        {
            if (ModelState.IsValid)
            {
                DB.Add(model);
                await DB.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
コード例 #29
0
        public async Task <IActionResult> Create([Bind("Id,Name,Headline,Content")] BlogModel blogModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blogModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(blogModel));
        }
コード例 #30
0
        public IActionResult Create(string title, string text)
        {
            var blog = new BlogModel();

            blog.Title = title;
            blog.Text  = text;

            BlogRepository.Save(blog.ToBlog());


            return(RedirectToAction("Index"));
        }
コード例 #31
0
        public async Task <BlogModel> GetBlogComponentModelAsync(IEnumerable <ListItem> blogPages, int take, ClientContext ctx)
        {
            if (blogPages == null)
            {
                return(null);
            }

            var model = new BlogModel
            {
                BlogPosts = new List <BlogPost>()
            };

            foreach (var page in blogPages)
            {
                var base64Image = string.Empty;
                var hasDate     = DateTime.TryParse(page["PublishedDate1"].ToString(), out DateTime publishedDate);
                var heroId      = (page["Hero"] as FieldLookupValue).GetLookupFieldValue();
                var hero        = await ctx.GetHeroByIdAsync(heroId);

                if (publishedDate > DateTime.Now || publishedDate == DateTime.MinValue)
                {
                    continue;
                }

                if (hero != null)
                {
                    var attachments = ctx.LoadQuery(hero.AttachmentFiles.Include(a => a.ServerRelativeUrl));

                    await ctx.ExecuteQueryAsync();

                    var image = attachments.FirstOrDefault();

                    if (image != null)
                    {
                        base64Image = await ctx.GetImageAsBase64String(image.ServerRelativeUrl);
                    }
                }

                model.BlogPosts.Add(new BlogPost
                {
                    BlogPageId    = page.Id,
                    Title         = page["PageName"] as string,
                    PublishedDate = hasDate ? publishedDate : DateTime.MinValue,
                    Image         = base64Image,
                    Teaser        = (page["Text"] as string).StripAndTruncateHtml(150) + "..."
                });
            }

            model.BlogPosts = model.BlogPosts.OrderByDescending(b => b.PublishedDate)
                              .Take(take)
                              .ToList();
            return(model);
        }
コード例 #32
0
        // [Authorize(Roles = "User")]
        public IActionResult Detail(int?id)
        {
            BlogModel blogFromDb = new BlogModel();
            UserModel user       = new UserModel();

            blogFromDb = _unitOfWork.Blog.Get(id.GetValueOrDefault());
            int uid = blogFromDb.UserId;

            //var tag = blogFromDb.Tag.TagName;
            user = _unitOfWork.User.GetFirstOrDefault(e => e.UserName == User.FindFirst("UserName").Value);
            return(View(Tuple.Create(blogFromDb, user)));
        }
コード例 #33
0
        public ActionResult Category(string categoryName, BlogModel model)
        {
            ActionResult result = null;

            if (string.IsNullOrEmpty(categoryName))
            {
                model = this.GetCategoryModel();
            }
            else
            {
                model = this.GetCategoryModel(categoryName, model);
            }

            if (result == null)
            {
                result = View(model);
            }

            return result;
        }
コード例 #34
0
ファイル: ContentClient.cs プロジェクト: eCollobro/eCollabro
 /// <summary>
 /// GetBlog
 /// </summary>
 /// <param name="blogId"></param>
 /// <returns></returns>
 public BlogModel GetBlog(int blogId)
 {
     BlogModel blogResult = new BlogModel();
     ServiceResponse<BlogDC> blogResponse = _contentProxy.Execute(opt => opt.GetBlog(blogId));
     if (blogResponse.Status == ResponseStatus.Success)
     {
         blogResult = Mapper.Map<BlogDC, BlogModel>(blogResponse.Result);
     }
     else
     {
         HandleError(blogResponse.Status, blogResponse.ResponseMessage);
     }
     return blogResult;
 }
コード例 #35
0
        private BlogModel GetIndexModelByTitle(string title)
        {
            BlogModel model = new BlogModel();
            model.FeedId = string.Empty;
            model.FeedFormatter = this.ProviderSyndication.GetInfoWithNoItems();
            model.FeedFilter = new DataFilterSyndication() { Uri = title, Page = 0, PageSize = (int)$customNamespace$.Models.Enumerations.PageSizesAvailable.RowsPerPage10 };
            model.FeedItems = this.ProviderSyndication.GetByTitle(model.FeedFilter);
            model.BaseViewModelInfo.Title = model.FeedFormatter.Feed.Title.Text;
            if (model.FeedItems.TotalRows > 0)
            {
                model.BaseViewModelInfo.Title = model.FeedItems.Data.First().Item.Title.Text;
            }
            return model;
        }

        #endregion Methods
    }
コード例 #36
0
ファイル: BlogController.cs プロジェクト: eCollobro/eCollabro
        public ActionResult ManageBlog(int Id = 0, int catId = 0)
        {
            if (!SavePermissionsToViewBag(FeatureEnum.User))
                return Redirect("~/home/unauthorized");

            BlogModel BlogModel = new BlogModel();
            BlogModel.BlogId = Id;
            BlogModel.BlogCategoryId = catId;
            if (Request.IsAjaxRequest())
                return PartialView(BlogModel);
            else
                return View(BlogModel);
        }
コード例 #37
0
 private BlogModel GetIndexModel()
 {
     BlogModel model = new BlogModel();
     model.FeedId = string.Empty;
     model.FeedFormatter = this.ProviderSyndication.GetInfoWithNoItems();
     model.FeedFilter = new DataFilterSyndication() { Page = 0, PageSize = (int)$customNamespace$.Models.Enumerations.PageSizesAvailable.RowsPerPage10 };
     model.FeedItems = this.ProviderSyndication.GetLast(model.FeedFilter);
     model.BaseViewModelInfo.Title = model.FeedFormatter.Feed.Title.Text;
     return model;
 }
コード例 #38
0
        private BlogModel GetCategoryModel(string categoryName, BlogModel model)
        {
            model.FeedId = categoryName;

            if (this.RequestType() == HttpVerbs.Get)
            {
                model = new BlogModel()
                {
                    FeedId = categoryName,
                    FeedFilter = new DataFilterSyndication()
                    {
                        CategoryName = categoryName,
                        Page = 0,
                        PageSize = (int)$customNamespace$.Models.Enumerations.PageSizesAvailable.RowsPerPage10
                    }
                };
            }
            else
            {
                if (WebGrid<SyndicationItemFormatter, BlogModel, DataFilterSyndication>.IsWebGridEvent())
                {
                    this.ModelState.Clear();
                    model.FeedFilter = (DataFilterSyndication)WebGrid<SyndicationItemFormatter, BlogModel, DataFilterSyndication>.GetDataFilterFromPost();
                }
            }

            if (!string.IsNullOrEmpty(categoryName))
            {
                model.FeedItems = this.ProviderSyndication.GetByCategory(model.FeedFilter);
                model.FeedFormatter = this.ProviderSyndication.GetInfoWithNoItems();
                model.BaseViewModelInfo.Title = string.Format("{0} - {1}", categoryName, model.FeedFormatter.Feed.Title.Text);
            }

            return model;
        }
コード例 #39
0
ファイル: ContentClient.cs プロジェクト: eCollobro/eCollabro
        /// <summary>
        /// SaveBlog
        /// </summary>
        /// <param name="blog"></param>
        public void SaveBlog(BlogModel blog)
        {
            BlogDC blogDC = Mapper.Map<BlogModel, BlogDC>(blog);
            ServiceResponse<int> saveBlogResponse = _contentProxy.Execute(opt => opt.SaveBlog(blogDC));

            if (saveBlogResponse.Status != ResponseStatus.Success)
                HandleError(saveBlogResponse.Status, saveBlogResponse.ResponseMessage);
            else
                blog.BlogId = saveBlogResponse.Result;
        }
コード例 #40
0
 public HttpResponseMessage SaveBlog(BlogModel blogModel, int siteId)
 {
     ContentClientProcessor.UserContext.SiteId = siteId;
     ContentClientProcessor.SaveBlog(blogModel);
     return Request.CreateResponse(HttpStatusCode.OK, new { Message = CoreMessages.SavedSuccessfully, Id = blogModel.BlogId });
 }