// GET: Articles public ActionResult Index(string UriTitle) { ArticleModel model = new ArticleModel(UriTitle); if (model.Article != null) return View(model); else return Redirect("/"); }
public bool ActualizeArticle(ArticleModel article) { if (_newArticleModels.Contains(article)) { _newArticleModels.Remove(article); _newArticleModels.Insert(0, article); if (!_aktualizeArticlesTasks.Any()) { var tsk = AktualizeArticlesTask().ContinueWith(DeleteTaskFromList); _aktualizeArticlesTasks.Add(tsk); } return true; } return false; }
private async Task InsertOrUpdateArticleAndTraces(ArticleModel article, IDataService dataService) { try { using (var unitOfWork = new UnitOfWork(false)) { article.PrepareForSave(); var addimages = new List<ImageModel>(); var updateimages = new List<ImageModel>(); //article var addgalleries = new List<GalleryModel>(); var updategalleries = new List<GalleryModel>(); var addgalleryImages = new List<ImageModel>(); var updategalleryImages = new List<ImageModel>(); var addcontents = new List<ContentModel>(); var updatecontents = new List<ContentModel>(); var articleRepo = new GenericRepository<ArticleModel, ArticleEntity>(dataService); var imageRepo = new GenericRepository<ImageModel, ImageEntity>(dataService); var galleryRepo = new GenericRepository<GalleryModel, GalleryEntity>(dataService); var contentRepo = new GenericRepository<ContentModel, ContentEntity>(dataService); if (article.LeadImage != null) { if (article.LeadImage.Id == 0) addimages.Add(article.LeadImage); else updateimages.Add(article.LeadImage); } if (article.Content != null && article.Content.Any()) { foreach (var contentModel in article.Content) { if (contentModel.Id == 0) addcontents.Add(contentModel); else updatecontents.Add(contentModel); if (contentModel.ContentType == ContentType.Gallery && contentModel.Gallery != null) { if (contentModel.Gallery.Id == 0) addgalleries.Add(contentModel.Gallery); else updategalleries.Add(contentModel.Gallery); if (contentModel.Gallery.Images != null) { foreach (var imageModel in contentModel.Gallery.Images) { if (imageModel.Id == 0) addgalleryImages.Add(imageModel); else updategalleryImages.Add(imageModel); } addgalleryImages.AddRange(contentModel.Gallery.Images); } } else if (contentModel.ContentType == ContentType.Image && contentModel.Image != null) { if (contentModel.Image.Id == 0) addimages.Add(contentModel.Image); else updateimages.Add(article.LeadImage); } } } if (article.Themes != null) await _themeRepository.SetThemesByArticle(article.Id, article.Themes.Select(t => t.Id).ToList()); if (article.RelatedArticles != null) await SetRelatedArticlesByArticleId(article.Id, article.RelatedArticles.Select(t => t.Id).ToList(), dataService); await imageRepo.AddAll(addimages); await galleryRepo.AddAll(addgalleries); await imageRepo.AddAll(addgalleryImages); await contentRepo.AddAll(addcontents); if (article.Id == 0) await articleRepo.Add(article); else await articleRepo.Update(article); await imageRepo.UpdateAll(updateimages); await galleryRepo.UpdateAll(updategalleries); await imageRepo.UpdateAll(updategalleryImages); await contentRepo.UpdateAll(updatecontents); await _themeRepository.SaveChanges(); await unitOfWork.Commit(); } } catch (Exception ex) { LogHelper.Instance.Log(LogLevel.Error, this, "Article cannot be saved", ex); } }
public static Article ToEntity(this ArticleModel model, Article destination) { return(model.MapTo(destination)); }
private async Task <MediaModel> SaveToDatabase(ImageUploadResult uploadResult, string fileNameLong, ArticleModel article = null) { var fileName = Path.GetFileNameWithoutExtension(fileNameLong); var medium = new MediaModel { Id = uploadResult.PublicId, Url = uploadResult.SecureUri.AbsoluteUri, Name = fileName, Description = fileName, Type = uploadResult.Format, Article = article, Length = ConvertBytesToMegabytes(uploadResult.Length) }; await _context.Medias.AddAsync(medium); await _context.SaveChangesAsync(); return(medium); }
public Data.Entities.Article CreateArticleFromModel(ArticleModel model) { return(_factory.CreateArticleFromModel(model)); }
public ActionResult <ResultModel> UpdateArticle(ArticleModel model) { return(_articleService.UpdateArticle(model)); }
public PublishModel(ArticleModel model, IUserService service, ArticleService articleService) : base(service) { _model = model; _articleService = articleService; }
public override Task <bool> EvaluateArticle(ArticleModel articleModel) { return(ExecuteSafe(async() => { var article = await DownloadAsync(articleModel); var doc = new HtmlDocument(); doc.LoadHtml(article); var articleColumn = doc.DocumentNode .Descendants("div") .FirstOrDefault(o => o.GetAttributeValue("id", null) != null && o.GetAttributeValue("id", null).Contains("js-article-column")); if (articleColumn == null) { return false; } var content = articleColumn.Descendants("p").Where(d => d.GetAttributeValue("class", null) != "obfuscated" && d.GetAttributeValue("class", null) != "einestages-forum-info").ToArray(); var encryptedContent = articleColumn.Descendants("p").Where(d => d.GetAttributeValue("class", null) == "obfuscated").ToArray(); if (string.IsNullOrEmpty(articleModel.Author)) { var authorBox = articleColumn.Descendants("div").Where(d => d.GetAttributeValue("class", null) == "asset-box asset-author-box"); var authorP = authorBox.FirstOrDefault()?.Descendants("p"); var author = authorP?.FirstOrDefault()?.Descendants("b").FirstOrDefault(); articleModel.Author = author?.InnerText; } articleModel.Content.Clear(); if (content != null && content.Any()) { var html = content.Aggregate("", (current, htmlNode) => current + htmlNode.OuterHtml); articleModel.Content.Add(new TextContentModel() { Content = HtmlConverter.CreateOnce(articleModel.Feed.Source.PublicBaseUrl).HtmlToParagraph(CleanHtml(html)) }); } if (encryptedContent != null && encryptedContent.Any()) { foreach (var htmlNode in encryptedContent) { htmlNode.InnerHtml = DecryptContent(htmlNode.InnerHtml); } var html = encryptedContent.Aggregate("", (current, htmlNode) => current + htmlNode.OuterHtml); articleModel.Content.Add(new TextContentModel() { Content = HtmlConverter.CreateOnce(articleModel.Feed.Source.PublicBaseUrl).HtmlToParagraph(CleanHtml(html)) }); } if (string.IsNullOrWhiteSpace(articleModel.Author)) { articleModel.Author = "Spiegel"; } return content?.Length > 0 || encryptedContent?.Length > 0; })); }
public ActionResult ArticleGroupInsert(GridCommand command, ArticleModel.ArticleGroupModel model) { int articleId = model.ArticleId; int artileGroupId = int.Parse(model.ArticleGroup); if (_articleService.GetArticleToGroupsByArticleId(articleId, 0, 2147483647, true).FindArticleToGroup(artileGroupId, articleId) == null) { var articleToGroup = new ArticleToGroup { ArticleId = articleId, ArticleGroupId = artileGroupId, DisplayOrder = model.DisplayOrder }; _articleService.InsertArticleToGroup(articleToGroup); } return ArticleGroupList(command, articleId); }
private void PrepareArticleModel(ArticleModel model) { if (model == null) { throw new ArgumentNullException("ArticleModel"); } model.NumberOfAvailableGroups = _articleService.GetAllArticleGroups().Count; }
protected void UpdateLocales(Article article, ArticleModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(article, x => x.Title, localized.Title, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(article, x => x.Short, localized.MetaKeywords, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(article, x => x.Full, localized.MetaKeywords, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(article, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(article, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(article, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(article, x => x.SeName, localized.SeName, localized.LanguageId); } }
public ActionResult Edit(ArticleModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews)) return AccessDeniedView(); var article = _articleService.GetArticleById(model.Id); if (article == null) //No news item found with the specified id return RedirectToAction("List"); if (ModelState.IsValid) { article = model.ToEntity(article); article.StartDateUtc = model.StartDate; article.EndDateUtc = model.EndDate; _articleService.UpdateArticle(article); //search engine name model.SeName = article.ValidateSeName(model.SeName, article.Title, true); _urlRecordService.SaveSlug(article, model.SeName, 0); //locales UpdateLocales(article, model); _articleService.UpdateArticle(article); SuccessNotification(_localizationService.GetResource("Toi.Plugin.Misc.Articles.Article.Updated")); return continueEditing ? RedirectToAction("Edit", new { id = article.Id }) : RedirectToAction("List"); } PrepareArticleModel(model); return View(model); }
public ActionResult Create(ArticleModel model, bool continueEditing) { if (ModelState.IsValid) { var article = model.ToEntity(); article.StartDateUtc = model.StartDate; article.EndDateUtc = model.EndDate; article.CreatedOnUtc = DateTime.UtcNow; _articleService.InsertArticle(article); //search engine name model.SeName = article.ValidateSeName(model.SeName, article.Title, true); _urlRecordService.SaveSlug(article, model.SeName, 0); //locales UpdateLocales(article, model); _articleService.UpdateArticle(article); SuccessNotification(_localizationService.GetResource("Toi.Plugin.Misc.Articles.Article.Added")); return continueEditing ? RedirectToAction("Edit", new { id = article.Id }) : RedirectToAction("List"); } return View(model); }
private async Task<ArticleModel> ActualizeArticle(ArticleModel article, IMediaSourceHelper sh) { try { if (sh.NeedsToEvaluateArticle()) { if (article.LeadImage?.Url != null && !article.LeadImage.IsLoaded) { article.LeadImage.Image = await Download.DownloadImageAsync(article.LeadImage.Url); article.LeadImage.IsLoaded = true; } string articleresult = await Download.DownloadStringAsync(article.LogicUri); var tuple = await sh.EvaluateArticle(articleresult, article); if (tuple.Item1) { if (sh.WriteProperties(ref article, tuple.Item2)) { article.State = ArticleState.Loaded; ArticleHelper.Instance.OptimizeArticle(ref article); } else { article.State = ArticleState.WritePropertiesFaillure; } } else { article.State = ArticleState.EvaluateArticleFaillure; } } else { article.State = ArticleState.Loaded; ArticleHelper.Instance.OptimizeArticle(ref article); } ArticleHelper.Instance.AddWordDumpFromArticle2(ref article); return article; } catch (Exception ex) { if (article != null) LogHelper.Instance.Log(LogLevel.Error, this, "ActualizeArticle failed! Source: " + article.SourceConfigurationId + " URL: " + article.PublicUri, ex); } return article; }
public async Task <bool> SetArticleFavoriteStateAsync(ArticleModel am, bool isFavorite) { am.IsFavorite = isFavorite; return(true); }
public void EditArticle(ArticleModel articleModel) { var article = _mapper.Map <Article>(articleModel); _repository.Update(article); }
public async Task <bool> DeleteAsync(ArticleModel article, CommentModel comment) { return(await DeleteAsync(article.Slug, comment.Id)); }
public new void ProcessRequest(HttpContext context) { try { int articleId = GetFormValue("articleId", 0); string auth = GetFormValue("auth", ""); string json = string.Empty; int userId = 0; if (!string.IsNullOrEmpty(auth)) { userId = UserLogic.GetUserIdByAuthToken(auth); if (userId == 0) { json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.令牌失效)); context.Response.ContentType = "application/json"; context.Response.Write(json); context.Response.End(); } } ArticleModel data = ArticleLogic.GetModel(articleId); if (data != null) { if (!string.IsNullOrEmpty(data.ArticleCover)) { data.ArticleCover = WebConfig.articleDetailsDomain() + data.ArticleCover; } else { data.ArticleCover = "http://" + context.Request.Url.Host + "/app/images/appShareLogo.png"; } } json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.OK, data)); //相同的资讯是否被一个人浏览(cookie + Ip) string clientip = GetClientIP; string cookieKey = "HOTBMUSER" + articleId.ToString(); string cookie = CookieHelper.GetCookieVal(cookieKey); if (string.IsNullOrEmpty(cookie) && userId == 0) { cookie = Guid.NewGuid().ToString("n"); CookieHelper.SetCookieValByCurrentDomain(cookieKey, 1, cookie); } else { cookie = string.Empty; } if (cookie.Length != 32 && userId == 0) { goto Finish; } ReadLogModel logModel = new ReadLogModel() { UserId = userId, cookie = cookie, ClientIp = clientip, ArticleId = articleId, IsRead = 1, ReadTime = DateTime.Now }; if (data != null) { int type = data.AuthorIdentity; //判断是否已经阅读 if (!LogLogic.IsRead(articleId, type, userId, cookie, clientip)) { //添加阅读日志 if (type == 3 || type == 4) { if (LogLogic.IsRead(userId, articleId)) { LogLogic.UpdateReadStatus(userId, articleId); } else { LogLogic.AddReadLog(logModel); } } else { LogLogic.AddReadLog(logModel); } ArticleLogic.UpdateArticleAmount(articleId); } } goto Finish; Finish: context.Response.ContentType = "application/json"; context.Response.Write(json); } catch (Exception ex) { LogHelper.Log(string.Format("message:{0},StackTrace:{1}", ex.Message, ex.StackTrace), LogHelperTag.ERROR); } }
public ActionResult Create() { ViewBag.AllLanguages = _languageService.GetAllLanguages(true); var model = new ArticleModel(); AddLocales(_languageService, model.Locales); model.Published = true; return View(model); }
public ViewArticleViewModel(ArticleModel article) { this.Slug = article.Slug; this.Article = article; }
public ArticleModel UpdateArticleModel(ArticleModel model) { return(_factory.UpdateArticleModel(model)); }
public ViewArticleViewModel(string slug) { this.Slug = slug; this.Article = ArticleModel.GetArticleBySlug(slug); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <returns></returns> public PagedQueryArticleResponse PagedQueryArticles(PagedQueryArticleRequest request) { var page = request.Page ?? 1; var pageSize = request.PageSize ?? 20; ArticleModel model = null; using (var client = DbFactory.GetClient()) { model = client.Queryable <ArticleModel>().InSingle(request.ArticleModelId); } if (model == null) { throw new AlertException("找不到文章模型"); } //设置字段 var articleProperties = GenericCache <ArticleTypeInfo> .GetOrSet(() => new ArticleTypeInfo { PropertyInfos = typeof(Article).GetProperties() }) .PropertyInfos; var configs = JsonConvert.DeserializeObject <List <ArticleConfiguration> >(model.Configuration); var selectFields = configs.Where(it => it.IsEnable && it.IsShowedInList) .Select(it => { var sugarColumn = articleProperties .FirstOrDefault(x => x.Name.Equals(it.FiledName, StringComparison.OrdinalIgnoreCase)) .GetCustomAttribute <SugarColumn>(); return(sugarColumn == null ? it.FiledName : sugarColumn.ColumnName); }).ToArray().Join(","); selectFields += selectFields.IsNullOrEmpty() ? "id,category_id" : ",id,category_id"; //类别 var categories = new long[] { }; //if (request.CategoryId > 0) // categories = _categoryService.GetChildrenIdsByParentId(request.CategoryId).ToArray(); using (var client = DbFactory.GetClient()) { var total = 0; var query = client.Queryable <Article>() .Where(it => it.ArticleTypeId == request.ArticleModelId) .WhereIF(request.CategoryId > 0, it => categories.Contains(it.CategoryId.Value)); query = query.Select(selectFields); var list = query .OrderBy("id DESC") .ToPageList(page, pageSize, ref total); return(new PagedQueryArticleResponse() { List = list.Select(it => new QueryArticleItem { Id = it.Id, CategoryId = it.CategoryId, Title = it.Title, SubTitle = it.SubTitle, TitleColor = it.TitleColor, TitleBold = it.TitleBold, Summary = it.Summary, Content = it.Content, Tags = it.Tags, ThumbImage = it.ThumbImage.GetFullPath(), Video = it.Video, Source = it.Source, Author = it.Author, Hits = it.Hits, Addtime = it.Addtime, OrderIndex = it.OrderIndex, IsTop = it.IsTop, IsRecommend = it.IsRecommend, SeoTitle = it.SeoTitle, SeoKeyword = it.SeoKeyword, SeoDescription = it.SeoDescription, String1 = it.String1, String2 = it.String2, String3 = it.String3, String4 = it.String4, Int1 = it.Int1, Int2 = it.Int2, Int3 = it.Int3, Int4 = it.Int4, Decimal1 = it.Decimal1, Decimal2 = it.Decimal2, Decimal3 = it.Decimal3, Decimal4 = it.Decimal4, Datetime1 = it.Datetime1, Datetime2 = it.Datetime2, Datetime3 = it.Datetime3, Datetime4 = it.Datetime4, Bool1 = it.Bool1, Bool2 = it.Bool2, Bool3 = it.Bool3, Bool4 = it.Bool4, Text1 = it.Text1, Text2 = it.Text2, Text3 = it.Text3, Text4 = it.Text4 }).ToList(), Page = page, PageSize = pageSize, TotalCount = total }); } }
public async Task <ArticleModel> UpdateArticleAsync(ClaimsPrincipal claimsPrincipal, [Service] IArticleResolver articleResolver, ArticleModel criterias) { return(await articleResolver.UpdateArticleAsync(claimsPrincipal, criterias)); }
public static Article ToEntity(this ArticleModel model) { return(model.MapTo <ArticleModel, Article>()); }
/// <summary> /// Response for Edit Constuctor /// </summary> /// <param name="articleModel"></param> public EditArticleResponse(ArticleModel articleModel) { this.Article = articleModel; }
private Task <bool> ArticleToArticleModel(NzzArticle na, ArticleModel am) { return(ExecuteSafe(async() => { am.Content.Clear(); for (int i = 0; i < na.body.Length; i++) { if (na.body[i].style == "h4") { na.body[i].style = "h2"; } if (na.body[i].style == "h3") { na.body[i].style = "h1"; } string starttag = "<" + na.body[i].style + ">"; string endtag = "</" + na.body[i].style + ">"; if (string.IsNullOrWhiteSpace(na.body[i].text)) { foreach (var nzzBox in na.body[i].boxes) { if (nzzBox.type == "image") { var uri = ParseImageUri(nzzBox.path); if (uri != null) { am.Content.Add(new ImageContentModel() { Url = uri, Text = TextHelper.TextToTextModel(nzzBox.caption) }); } } else if (nzzBox.type == "video" || nzzBox.type == "html") { //dont do shit } else if (nzzBox.type == "infobox") { var newContent = HtmlConverter.CreateOnce(am.Feed.Source.PublicBaseUrl).HtmlToParagraph("<p>" + nzzBox.body + "</p>"); foreach (var paragraphModel in newContent) { var ntm = new TextModel() { Children = paragraphModel.Children, TextType = TextType.Cursive }; paragraphModel.Children = new List <TextModel> { ntm }; } if (!string.IsNullOrWhiteSpace(nzzBox.title)) { newContent.Insert(0, new ParagraphModel() { ParagraphType = ParagraphType.Title, Children = new List <TextModel>() { new TextModel() { Text = nzzBox.title, TextType = TextType.Cursive } } }); } if (newContent.Any()) { am.Content.Add(new TextContentModel() { Content = newContent }); } } else { LogHelper.Instance.LogInfo("nzz content type not found: " + nzzBox.mimeType, this); } } } else { if (!na.body[i].text.StartsWith("Mehr zum Thema")) { var content = HtmlConverter.CreateOnce(am.Feed.Source.PublicBaseUrl).HtmlToParagraph(starttag + na.body[i].text + endtag); if (content != null && content.Count > 0) { am.Content.Add(new TextContentModel() { Content = content }); } } } } if (!am.Content.Any()) { am.Content.Add(TextHelper.TextToTextModel("Der Inhalt dieses Artikels wird nicht unterstützt. Öffne den Artikel im Browser um mehr zu sehen.")); } if (na.authors != null) { foreach (var nzzAuthor in na.authors) { if (!string.IsNullOrEmpty(nzzAuthor.name)) { am.Author = nzzAuthor.name; if (!string.IsNullOrEmpty(nzzAuthor.abbreviation)) { am.Author += ", " + nzzAuthor.abbreviation; } } else { am.Author = nzzAuthor.abbreviation; } } } if (!string.IsNullOrEmpty(na.agency)) { am.Author += " " + na.agency; } if (string.IsNullOrWhiteSpace(am.Author)) { am.Author = "NZZ"; } if (!string.IsNullOrEmpty(na.leadText)) { am.Teaser = na.leadText; } am.Themes.Clear(); await AddThemesAsync(am, na.departments); return true; })); }
public ActionResult create(string title, string content, string ids) { var user = GetUserData(); ArticleModel model = new ArticleModel(); model.ArticleBody = content; model.ArticleIntro = content; model.ArticleTitle = title; model.ArticleCover = ""; model.ArticleStatus = 1; model.AuthorId = user.UserId; model.AuthorIdentity = user.UserIdentity == 0 ? 4 : 3; model.AuthorName = user.RealName; model.EnablePublish = 1; model.EnableTop = 0; model.PublishTime = DateTime.Now; model.TopTime = DateTime.Now; model.UpdateTime = DateTime.Now; //如果当前创建资讯的用户身份为盟友,则发送目标为盟主的ID //如果当前创建资讯的用户身份为盟主时,则发送目标为 2(盟友) model.SendTargetId = user.UserIdentity == 1 ? 2 : user.BelongOne; string[] TargetIds = null; //如果是盟主身份,则需要判断发送目标 if (user.UserIdentity == 1) { if (string.IsNullOrEmpty(ids)) { return(Json(new ResultModel(ApiStatusCode.缺少发送目标))); } TargetIds = ids.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (TargetIds.Length <= 0) { return(Json(new ResultModel(ApiStatusCode.缺少发送目标))); } } int articleId = ArticleLogic.AddArticle(model); ApiStatusCode apiCode = ApiStatusCode.OK; if (articleId > 0) { ReadLogModel logModel = new ReadLogModel() { ArticleId = articleId, ClientIp = "", cookie = "", IsRead = 0, ReadTime = DateTime.Now }; if (user.UserIdentity == 1) { foreach (var TargetId in TargetIds) { logModel.UserId = Convert.ToInt32(TargetId); LogLogic.AddReadLog(logModel); } } else { logModel.UserId = user.BelongOne; LogLogic.AddReadLog(logModel); } } else { apiCode = ApiStatusCode.发送失败; } return(Json(new ResultModel(apiCode))); }
public ActionResult AdminEdit(int id) { var obj = MyService.GetVArticleById(id); var model = new ArticleModel { Id = obj.id, CateId = obj.cateid, Title = Utils.FileterStr(obj.title), Summary = string.IsNullOrWhiteSpace(obj.summary) ? "" : obj.summary, Content = string.IsNullOrWhiteSpace(obj.content) ? "" : obj.content, Tags = string.IsNullOrWhiteSpace(obj.tags) ? "" : obj.tags, SeoDescription = string.IsNullOrWhiteSpace(obj.seodescription) ? "" : obj.seodescription, Seokeywords = string.IsNullOrWhiteSpace(obj.seokeywords) ? "" : obj.seokeywords, SeoMetas = string.IsNullOrWhiteSpace(obj.seometas) ? "" : obj.seometas, SeoTitle = string.IsNullOrWhiteSpace(obj.seotitle) ? "" : obj.seotitle, ReName = WebUtils.MyString(obj.rename), Status = obj.status, ReplyPermit = obj.replypermit, IsCommend = obj.iscommend, IsTop = obj.istop, IsIndexTop = obj.isindextop, CreateDate = obj.createdate, ArticleTypeId = obj.typeid }; var navSelectedItem = string.Empty; switch (obj.typeid) { case 1: navSelectedItem = "article"; break; case 2: navSelectedItem = "singlePage"; break; case 4: navSelectedItem = "album"; break; case 6: navSelectedItem = "message"; break; case 5: navSelectedItem = "posts"; break; case 7: navSelectedItem = "customArea"; break; case 8: navSelectedItem = "customGlobalArea"; break; } ViewBag.NavSelectedItem = navSelectedItem; ViewData["CateId"] = new SelectList(MyService.GetFCategoryList(obj.typeid.ToString(), "", " -- "), "CateId", "ViewName", model.CateId); if (obj.typeid == 4) { return(View("AdminAlbumEdit", model)); } return(View(model)); }
//add or edit protected void Button1_Click(object sender, EventArgs e) { ArticleModel ma = new ArticleModel(); ma.Title = txtTitle.Text.Trim(); int ctid = BasePage.GetRequestId(Request.Form["txtTid"]); ma.Tid = ctid; ma.FullTitle = txtFullTitle.Text; ma.Px = BasePage.GetRequestId(txtPx.Text); ma.Author = txtAuthor.Text; ma.Origin = txtOrigin.Text; ma.Hits = BasePage.GetRequestId(txtHist.Text); if (!String.IsNullOrEmpty(txtAddDate.Text)) { ma.AddDate = DateTime.Parse(txtAddDate.Text); } else { ma.AddDate = DateTime.Now; } ma.EditDate = DateTime.Now; ma.PicUrl = txtPicUrl.Text; ma.SeoKeyword = txtKeyWord.Text; ma.Intro = txtIntro.Text; string contents1 = txtcontents.Text; if (txtspanfont.Checked)//过滤span font { contents1 = Regex.Replace(contents1, "(<span[^>]+>)|(</span>)", ""); contents1 = Regex.Replace(contents1, "(<font[^>]+>)|(</font>)", "");//font } if (txthtml.Checked) { contents1 = BasePage.HtmlFilter(contents1); } ma.Contents = contents1; ma.Contents2 = txtcontents2.Text; ma.Contents3 = txtcontents3.Text; ma.Owner = Cookies.GetCookie("User_Name"); ma.SeoDescription = txtDescription.Text; if (!String.IsNullOrEmpty(txtseotitle.Text)) { ma.SeoTitle = txtseotitle.Text; } else { ma.SeoTitle = txtTitle.Text; } ma.Languagen = int.Parse(Drlanguage.SelectedValue); ma.IsPopular = txtPopular.Checked ? 1 : 0; ma.IsRecommend = txtRecommend.Checked ? 1 : 0; ma.IsNew = txtNew.Checked ? 1 : 0; ma.FilesUrl = filesurl.Text; ma.TitltColor = colortxt.Value; ma.AllowComment = int.Parse(rallowcomment.SelectedValue); if (BasePage.ArrayExist(Cookies.GetCookie("ModelPower"), "ms" + mid)) { ma.Verific = 1; } else { ma.Verific = 0; } ma.id = id; //扩展字段 string _sql = ""; int modeexists = new CommonBll().GetRecordCount("GL_ModelField", "FieldOnOff=0 and Modeid=" + mid); if (modeexists > 0) { string[] _atype = Request.Params.GetValues("hideFieldType"); //类型 string[] _atitle = Request.Params.GetValues("hideFieldTitle"); // string[] _bcontents = Request.Params.GetValues("txtFieldContent"); if (_atype != null && _atitle != null && _bcontents != null) { for (int i = 0; i < _atitle.Length; i++) { string vv = "'" + _bcontents[i] + "'"; if (_atype[i].ToString() == "1") { //数值 vv = _bcontents[i]; } if (String.IsNullOrEmpty(_sql)) { _sql += _atitle[i] + "=" + vv; } else { _sql += "," + _atitle[i] + "=" + vv; } } } } if (id == 0) { ma.IsDel = 0; int i = new ArticleBll().Add(datatable, ma); if (i > 0) { //更新自定义 if (modeexists > 0) { bool bb = new ArticleBll().Updatezd(datatable, _sql, i); } BasePage.JscriptPrint(Page, "添加成功!", "Article.aspx?mid=" + mid + "&tid=" + ctid + "&language=" + Language);//添加成功返回当前栏目 } } else { bool b = new ArticleBll().Update(datatable, ma); if (b) { ////更新自定义 if (modeexists > 0) { bool bb = new ArticleBll().Updatezd(datatable, _sql, id); } BasePage.JscriptPrint(Page, "修改成功!", hiddenbackurl.Value.ToString()); } } }
public async Task ActualizeArticleAsync(ArticleModel am) { }
public async Task <bool> AddAsync(ArticleModel model) { model.Id = await SendRequestFor <int>(API.METHOD.ADD, model); return(model.Id != -1); }
public async Task <bool> MarkArticleAsReadAsync(ArticleModel am) { am.IsRead = true; return(true); }
public Task <bool> UpdateAsync(ArticleModel model, string token) { return(SendRequestFor <bool>(API.METHOD.UPDATE, model, token)); }
public async Task <ApiResponse <CommentResponse> > AddAsync(ArticleModel article, CommentModel value) { return(await AddAsync(article.Slug, value)); }
public IHttpActionResult GetArticleByDate() { FooterArticle Footer = new FooterArticle(); FooterArticleModel fa1, fa2, fa3; using (var context = new NewsEntities()) { var today = DateTime.Now; List <ArticleModel> x = new List <ArticleModel>(); fa1 = new FooterArticleModel(); var yesterday1 = today.AddDays(-1); List <Article> articles = context.Article.Where(f => f.Date.Value.Day == yesterday1.Day).OrderBy(a => a.Date).Take(2).ToList(); foreach (var A in articles) { var article = new ArticleModel(); article.ID = A.ID; article.Titre = A.Titre; article.Body = A.Body; article.Img = A.Img; article.Video = A.video; article.Date = A.Date.ToString(); x.Add(article); } fa1.listes = x; fa1.Img = context.Article.FirstOrDefault().Img; Footer.fam1 = fa1; fa2 = new FooterArticleModel(); List <ArticleModel> y = new List <ArticleModel>(); var yesterday2 = today.AddDays(-2); List <Article> articles1 = context.Article.Where(f => f.Date.Value.Day == yesterday2.Day).OrderBy(a => a.Date).Take(2).ToList(); foreach (var A in articles1) { var article = new ArticleModel(); article.ID = A.ID; article.Titre = A.Titre; article.Body = A.Body; article.Img = A.Img; article.Video = A.video; article.Date = A.Date.ToString(); y.Add(article); //fa2.listes.Add(article); } fa2.listes = y; fa2.Img = context.Article.FirstOrDefault().Img; Footer.fam2 = fa2; fa3 = new FooterArticleModel(); List <ArticleModel> z = new List <ArticleModel>(); var yesterday3 = today.AddDays(-3); List <Article> articles2 = context.Article.Where(f => f.Date.Value.Day == yesterday3.Day).OrderBy(a => a.Date).Take(2).ToList(); foreach (var A in articles2) { var article = new ArticleModel(); article.ID = A.ID; article.Titre = A.Titre; article.Body = A.Body; article.Img = A.Img; article.Video = A.video; article.Date = A.Date.ToString(); z.Add(article); //fa3.listes.Add(article); } fa3.listes = z; fa3.Img = context.Article.FirstOrDefault().Img; Footer.fam3 = fa3; } return(Ok(Footer)); }
public async Task <bool> DeleteAsync(ArticleModel article, int commentId) { return(await DeleteAsync(article.Slug, commentId)); }
public MyArticlesViewModel(string authorSlug) { this.UnpublishedArticles = ArticleModel.GetUnpublishedArticles(authorSlug); this.RecentPublishedArticles = ArticleModel.GetRecentArticlesByAuthor(authorSlug, this.MaxPublishedArticleCount); }
public IActionResult Create() { var model = new ArticleModel(); return(View(model)); }
public ActionResult ArticleGroupUpdate(GridCommand command, ArticleModel.ArticleGroupModel model) { ArticleToGroup articleToGroup = _articleService.GetArticleToGroupById(model.Id); if (articleToGroup == null) { throw new ArgumentException("articleToGroup"); } articleToGroup.ArticleGroupId = int.Parse(model.ArticleGroup); articleToGroup.DisplayOrder = model.DisplayOrder; _articleService.UpdateArticleToGroup(articleToGroup); return this.ArticleGroupList(command, articleToGroup.ArticleId); }