// // 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(); }
public ActionResult Blog(int Id = 0) { BlogModel blogModel = new BlogModel(); blogModel.BlogId = Id; if (Request.IsAjaxRequest()) return PartialView(blogModel); else return View(blogModel); }
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)); }
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); }
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()); }
public IActionResult WriteBlog() { BlogModel x = new BlogModel(); x._section = _Context.Sections.Where(p => p.ActiveZero == false).ToList(); return(View(x)); }
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()); }
// // 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()); }
/// <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); } }
/// <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); } }
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); }
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))); }
public static string DeclineComment(string id) { if (id != "") { int commentid = Convert.ToInt32(id); BlogModel objBlog = new BlogModel(); objBlog.CommentDecline(commentid); } return("Comment Decline Succesfully"); }
private void OnSelectedBookMark(BlogModel data) { if (data.IsOn) { UnFavorite(data); } else { Favorite(data); } }
// 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)); }
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); }
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); } }
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")); }
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 })); }
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)); }
public static string ApproveComments(string id) { if (id != "") { int commentid = Convert.ToInt32(id); BlogModel objBlog = new BlogModel(); objBlog.CommentApproved(commentid); } return("Comment Approve Succesfully"); }
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")); }
public IActionResult About() { ViewData["Message"] = "Your application description page."; var model = new BlogModel() { Blog = Blog }; return(View(model)); }
public IViewComponentResult Invoke(BlogModel model) { if (model == null) { return(View()); } else { return(View(model)); } }
public IActionResult Contact() { ViewData["Message"] = "Your contact page."; var model = new BlogModel() { Blog = Blog }; return(View(model)); }
public BlogModel DeletePost(int Id) { BlogModel post = context.Blog.Find(Id); if (post != null) { context.Blog.Remove(post); context.SaveChanges(); } return(post); }
public IActionResult Add(int?Id) { ViewBag.CategoryList = CategoryDAL.CategoryList(); BlogModel model = new BlogModel(); if (Id != null) { model = BlogDAL.GetBlogModel(Id.Value); } return(View(model)); }
public async Task <IActionResult> Create(BlogModel model) { if (ModelState.IsValid) { DB.Add(model); await DB.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }
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)); }
public IActionResult Create(string title, string text) { var blog = new BlogModel(); blog.Title = title; blog.Text = text; BlogRepository.Save(blog.ToBlog()); return(RedirectToAction("Index")); }
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); }
// [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))); }
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; }
/// <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; }
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 }
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); }
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; }
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; }
/// <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; }
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 }); }