Exemple #1
0
        public async Task <ActionResult> Details(ArticlesModel model)
        {
            var comment = model.ArticleCommentModel;

            comment.Status = (byte)ArticleStatus.JustCreated;
            comment.Date   = DateTime.Now;
            if (ModelState.IsValid)
            {
                string strUrl = APIProvider.APIGenerator(controllerName + "/Comment", APIConstant.ACTION_INSERT);
                var    result = await InvokeTransaction(comment, strUrl);

                if (result > 0)
                {
                    return(RedirectToAction("Details", new { id = comment.ArticleId }));
                }
                else
                {
                    model = await SetArticleComment(comment);

                    return(View("Details", model));
                }
            }
            else
            {
                model = await SetArticleComment(comment);

                return(View("Details", model));
            }
        }
Exemple #2
0
        /// <summary>
        ///  回复扫码推事件且弹出“消息接收中”提示框消息
        /// </summary>
        /// <param name="model">The model.</param>
        /// Author  : 俞立钢
        /// Company : 绍兴标点电子技术有限公司
        /// Created : 2014-10-13 16:09:53
        public static void ReplyScanCodeWaitmsg(Dictionary <string, string> model)
        {
            /*string value = model.ReadKey("ScanCodeInfo");
             * string content = string.Format("项目编号:{0};\n验收状态:{1};\n验收结果:{2};\n报表查看:<a href='{3}'>点击查看</a>", value.Substring(6), "完成", "通过", "http://www.sxajj.gov.cn/1.jpg");
             * ProduceText(model, content);*/
            List <ArticlesModel> articles = new List <ArticlesModel>();
            ArticlesModel        article  = new ArticlesModel();

            article.Title       = string.Format("{0}号项目", "一");
            article.Description = string.Format("项目编号:{0};验收状态:完成;验收结果:通过;", "CX2501");
            article.PicUrl      = "http://www.sxajj.gov.cn/1.jpg";
            article.Url         = "http://www.sxajj.gov.cn/1.jpg";
            articles.Add(article);
            ArticlesModel article = new ArticlesModel();

            article.Title       = string.Format("{0}号项目", "二");
            article.Description = string.Format("项目编号:{0};验收状态:完成;验收结果:通过;", "CX2502");
            article.PicUrl      = "http://www.sxajj.gov.cn/1.jpg";
            article.Url         = "http://www.sxajj.gov.cn/1.jpg";
            articles.Add(article);
            ProduceNews(model, articles);
            //生成图片

            /*string mediaId = "IBH9UW7Ptrvbs9rQHAnu2zonxeq5Jh0uL6WwuYauIEWNF0UlyVMecLV3ploxRc5X";
             * ProduceImage(model, mediaId);*/
        }
Exemple #3
0
        public IActionResult SaveItem(string Id = null)
        {
            ArticlesModel data           = new ArticlesModel();
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + HttpContext.Request.Headers["UserName"];
            int           IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchArticles()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            data.ListItemsDanhMuc = CategoriesArticlesService.GetListItems();
            data.ListItemsAuthors = API.Areas.Admin.Models.USUsers.USUsersService.GetListItemsAuthor(4);
            data.ListItemType     = ArticlesService.GetListItemsType();
            Articles Item = new Articles()
            {
                PublishUp = DateTime.Now, PublishUpShow = DateTime.Now.ToString("dd/MM/yyyy"), Status = true
            };

            if (IdDC > 0)
            {
                Item = ArticlesService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }

            data.Item = Item;
            return(View(data));
        }
        public ActionResult ArticleDetails(int id)
        {
            if (id == 0)
            {
                throw new ArgumentException($"Невозможно открыть статью с id=0 для чтения");
            }

            DynamicParameters articleParam = new DynamicParameters();

            articleParam.Add("@ArticleId", id);
            ArticlesModel articleModel = DapperORM.ReturnList <ArticlesModel>("GetArticleById", articleParam).FirstOrDefault <ArticlesModel>();

            if (articleModel == null)
            {
                throw new ArgumentException($"Не удалось найти статью с id={id} в базе данных");
            }

            DynamicParameters commentParam = new DynamicParameters();

            commentParam.Add("@ArticleId", id);
            List <CommentsModel> commentsModelList = DapperORM.ReturnList <CommentsModel>("GetCommentsByArticleId", commentParam).ToList();

            foreach (CommentsModel commentModel in commentsModelList)
            {
                RecursiveAddChildComments(articleModel.Id, commentModel);
            }

            articleModel.Comments = commentsModelList;
            return(View(articleModel));
        }
Exemple #5
0
        /// <summary>
        ///  回复扫码推事件且弹出“消息接收中”提示框消息
        /// </summary>
        /// <param name="model">The model.</param>
        /// Author  : 俞立钢
        /// Company : 绍兴标点电子技术有限公司
        /// Created : 2014-10-13 16:09:53
        public static void ReplyScanCodeWaitmsg(Dictionary <string, string> model)
        {
            string value = model.ReadKey("ScanCodeInfo");

            switch (value)
            {
            case "1":
                string content = string.Format("项目编号:{0};\n验收状态:{1};\n验收结果:{2};\n报表查看:<a href='{3}'>点击查看</a>", value.Substring(6), "完成", "通过", "http://www.sxajj.gov.cn/1.jpg");
                ProduceText(model, content);
                break;

            case "2":
                List <ArticlesModel> articles = new List <ArticlesModel>();
                ArticlesModel        article  = new ArticlesModel();
                article.Title  = string.Format("一号项目\n项目编号:CX2501;验收状态:完成;验收结果:通过;");
                article.PicUrl = "http://www.sxajj.gov.cn/1.jpg";
                article.Url    = "http://www.sxajj.gov.cn/1.jpg";
                articles.Add(article);
                article        = new ArticlesModel();
                article.Title  = string.Format("二号项目\n项目编号:CX2502;验收状态:完成;验收结果:通过;");
                article.PicUrl = "http://www.sxajj.gov.cn/1.jpg";
                article.Url    = "http://www.sxajj.gov.cn/1.jpg";
                articles.Add(article);
                ProduceNews(model, articles);
                break;
            }


            //生成图片
            string mediaId = "IBH9UW7Ptrvbs9rQHAnu2zonxeq5Jh0uL6WwuYauIEWNF0UlyVMecLV3ploxRc5X";

            ProduceImage(model, mediaId);
        }
Exemple #6
0
        /// <summary>
        ///  回复扫码推事件且弹出“消息接收中”提示框消息
        /// </summary>
        /// <param name="model">The model.</param>
        /// Author  : 俞立钢
        /// Company : 绍兴标点电子技术有限公司
        /// Created : 2014-10-13 16:09:53
        public static void ReplyScanCodeWaitmsg(Dictionary <string, string> model)
        {
            string value = model.ReadKey("ScanCodeInfo");

            switch (value)
            {
            case "1":
                string content = string.Format("项目编号:{0};\n验收状态:{1};\n验收结果:{2};\n报表查看:<a href='{3}'>点击查看</a>", value.Substring(6), "完成", "通过", "http://www.sxajj.gov.cn/1.jpg");
                ProduceText(model, content);
                break;

            case "2":
                List <ArticlesModel> articles = new List <ArticlesModel>();
                ArticlesModel        article  = new ArticlesModel();
                article.Title  = string.Format("一号项目\n项目编号:CX2501;验收状态:完成;验收结果:通过;");
                article.PicUrl = "http://www.sxajj.gov.cn/1.jpg";
                article.Url    = "http://www.sxajj.gov.cn/1.jpg";
                articles.Add(article);
                article        = new ArticlesModel();
                article.Title  = string.Format("二号项目\n项目编号:CX2502;验收状态:完成;验收结果:通过;");
                article.PicUrl = "http://www.sxajj.gov.cn/1.jpg";
                article.Url    = "http://www.sxajj.gov.cn/1.jpg";
                articles.Add(article);
                ProduceNews(model, articles);
                break;
            }
        }
        private string GetHtmlMessageBody(User user, string unsubscribeToken, List <Article> articles,
                                          ScheduleType scheduleType, Template articlesEmailTemplate)
        {
            unsubscribeToken = WebUtility.UrlEncode(unsubscribeToken);

            var model = new ArticlesModel
            {
                UserName       = user.Name,
                UserEmail      = user.Email,
                Period         = GetPeriod(scheduleType),
                UnsubscribeUrl = $"{_webUiBasePath}/unsubscribe/{unsubscribeToken}",
                ViewOnSiteUrl  = $"{_webUiBasePath}/articles/sent",
                Articles       = articles.Select(a => new ArticleModel
                {
                    Title        = a.Title,
                    Description  = a.Description,
                    Url          = $"{_webUiBasePath}/articles/{a.Id}/user/{user.Id}",
                    PublicatedAt = GetDate(a.PublicatedAt),
                    ReadTime     = a.ReadTime,
                    PdfUrl       = $"{_webUiBasePath}/articles/{a.Id}",
                    AuthorEmail  = a.AuthorEmail,
                    AuthorName   = a.AuthorName,
                    AuthorPhoto  = a.AuthorPhoto
                }).ToList()
            };

            return(articlesEmailTemplate.Render(new { Model = model }));
        }
Exemple #8
0
        /// <summary>
        ///  回复关注事件的消息
        /// </summary>
        /// <param name="model">The model.</param>
        /// Author  : 俞立钢
        /// Company : 绍兴标点电子技术有限公司
        /// Created : 2014-10-24 14:10:31
        public static void ReplaySubscribeText(Dictionary <string, string> model)
        {
            List <ArticlesModel> articles = new List <ArticlesModel>();
            ArticlesModel        article  = new ArticlesModel();

            article.Title = "欢迎关注绍兴标点电子公司";
            articles.Add(article);
            article             = new ArticlesModel();
            article.Title       = "【公司介绍】";
            article.Description = "";
            articles.Add(article);
            article       = new ArticlesModel();
            article.Title = "欢迎关注绍兴标点电子公司";
            articles.Add(article);
            article       = new ArticlesModel();
            article.Title = "欢迎关注绍兴标点电子公司";
            articles.Add(article);
            article       = new ArticlesModel();
            article.Title = "欢迎关注绍兴标点电子公司";
            articles.Add(article);
            StringBuilder sb = new StringBuilder();

            sb.Append("<B>欢迎关注绍兴标点电子公司<B>\n");
            sb.Append("<br/>");
            sb.Append("【公司介绍】\n");
            sb.Append("开发、销售:电子产品、工控设备;开发:电脑软件;销售:电脑及耗材;计算机软硬件的技术咨询、技术服务、技术转让。");
            sb.Append("<br/>");
            sb.Append("【公司地址】\n");
            sb.Append("中国浙江省绍兴市越城区舜江路683号科创大厦705室");
            sb.Append("<br/>");
            sb.Append("【公司微信】\n");
            sb.Append("SxBdDzKjYxGs");
            sb.Append("<br/>");
            ProduceText(model, sb.ToString());
        }
Exemple #9
0
        public ActionResult Create()
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý bài viết"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thêm thông tin bài viết"), Url = Url.Action("Index")
            });
            var model = new ArticlesModel();

            var result = new ControlFormResult <ArticlesModel>(model);

            result.Title                = this.T("Thêm thông tin bài viết");
            result.FormMethod           = FormMethod.Post;
            result.UpdateActionName     = "Update";
            result.ShowCancelButton     = false;
            result.ShowBoxHeader        = false;
            result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            result.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;

            result.RegisterFileUploadOptions("Image.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            result.AddAction().HasText(this.T("Thêm mới")).HasUrl(this.Url.Action("Create")).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);

            result.RegisterExternalDataSource(x => x.CategoryId, BindCategories());

            return(result);
        }
Exemple #10
0
        public IActionResult Index([FromQuery] SearchArticles dto)
        {
            int    TotalItems     = 0;
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + HttpContext.Request.Headers["UserName"];

            dto.IdCoQuan = int.Parse(HttpContext.Request.Headers["IdCoQuan"]);
            ArticlesModel data = new ArticlesModel()
            {
                SearchData = dto
            };

            data.ListItems          = ArticlesService.GetListPagination(data.SearchData, API.Models.Settings.SecretId + ControllerName);
            data.ListItemsDanhMuc   = CategoriesArticlesService.GetListItems();
            data.ListItemsAuthors   = API.Areas.Admin.Models.USUsers.USUsersService.GetListItemsAuthor(4);
            data.ListItemsCreatedBy = API.Areas.Admin.Models.USUsers.USUsersService.GetListItemsAuthor(3);
            data.ListItemsStatus    = ArticlesService.GetListItemsStatus();
            if (data.ListItems != null && data.ListItems.Count() > 0)
            {
                TotalItems = data.ListItems[0].TotalRows;
            }
            HttpContext.Session.SetString("STR_Action_Link_" + ControllerName, Request.QueryString.ToString());
            data.Pagination = new Models.Partial.PartialPagination()
            {
                CurrentPage = data.SearchData.CurrentPage, ItemsPerPage = data.SearchData.ItemsPerPage, TotalItems = TotalItems, QueryString = Request.QueryString.ToString()
            };

            return(View(data));
        }
Exemple #11
0
        //public bool Update(ArticlesModel model)
        //{
        //    try
        //    {
        //        var article = db.NewsArticles.Find(model.id);
        //        article.headline = article.headline;
        //        article.byLine = article.byLine;
        //        article.source = article.source;
        //        article.text = article.text;
        //        article.lastModifiedDate = DateTime.Now;

        //        var articleCategory = db.NewsArticleCategories.Where(a => a.newsArticleID == model.id).SingleOrDefault();
        //        articleCategory.newsCategoryID = articleCategory

        //        return true;
        //    }
        //    catch (Exception ex)
        //    {
        //        return false;
        //    }s
        //}
        public ActionResult Details(int id)
        {
            var user = new NewsArticles().ViewDetail(id);

            Models.ArticlesModel objArticle = new ArticlesModel();
            // Parse data
            objArticle.id           = user.id;
            objArticle.CategoryID   = user.CategoryID;
            objArticle.newsCategory = db.NewsCategories.Find(user.CategoryID).name;
            objArticle.headline     = user.headline;
            objArticle.extract      = user.extract;
            objArticle.encoding     = user.encoding;
            objArticle.text         = user.text;
            objArticle.publishDate  = user.publishDate;
            objArticle.byLine       = user.byLine;
            objArticle.source       = user.source;
            objArticle.state        = user.state;
            //objArticle.clientQuote = user.clientQuote;
            objArticle.createdDate         = user.createdDate;
            objArticle.lastModifiedDate    = user.lastModifiedDate;
            objArticle.htmlMetaDescription = user.htmlMetaDescription;
            objArticle.htmlMetaKeywords    = user.htmlMetaKeywords;
            objArticle.htmlMetaLangauge    = user.htmlMetaLangauge;
            objArticle.tags     = user.tags;
            objArticle.priority = user.priority;
            //objArticle.format = user.format;
            objArticle.photoHtmlAlt = user.photoHtmlAlt;
            //objArticle.photoWidth = user.photoWidth;
            //objArticle.photoHeight = user.photoHeight;
            objArticle.photoURL = user.photoURL;
            ViewBag.Title       = objArticle.headline;
            return(View(objArticle));
        }
        public async Task <ActionResult <Articles> > PostArticles(ArticlesModel articlesModel)
        {
            var articles = new Articles()
            {
                ArticleId        = articlesModel.ArticleId,
                Name             = articlesModel.Name,
                HeroImage        = articlesModel.HeroImage,
                ShortDescription = articlesModel.ShortDescription,
                Description      = articlesModel.Description,
                PublicationDate  = articlesModel.PublicationDate,
                Category         = articlesModel.CategoryId
            };

            _context.Articles.Add(articles);
            await _context.SaveChangesAsync();

            for (int i = 0; i < articlesModel.Tags.Length; i++)
            {
                var articleTag = new ArticlesTags()
                {
                    ArticleId = articles.ArticleId,
                    TagId     = Convert.ToInt32(articlesModel.Tags[i])
                };

                _context.ArticlesTags.Add(articleTag);
            }


            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetArticles", new { id = articles.ArticleId }, articles));
        }
Exemple #13
0
        public async Task <ActionResult> Details(int id)
        {
            if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Edit))
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.Article, APIConstant.ACTION_UPDATE);
                return(RedirectToAction("Index"));
            }
            else
            {
                ArticlesModel model   = new ArticlesModel();
                var           article = await GetArticle(id);

                var comments = await GetComments(id);

                model.ArticleViewModel       = article;
                model.lstArticleCommentModel = comments;

                model.ArticleCommentModel = new ArticleCommentViewModel()
                {
                    CreatedUser = _userSession.UserId,
                    ArticleId   = id
                };
                return(View(model));
            }
        }
Exemple #14
0
        private void GetArticles()
        {
            string url = "https://www.wired.com/feed/";


            using (var stream = new ModifiedWebClient().OpenRead(url))
            {
                using (var sr = new StreamReader(stream))
                {
                    using (var reader = XmlReader.Create(sr))
                    {
                        Konular = new List <ArticlesModel>();

                        var feed = SyndicationFeed.Load(reader);
                        foreach (var item in feed.Items)
                        {
                            ArticlesModel makale = new ArticlesModel();
                            makale.Baslik  = item.Title.Text;
                            makale.KonuUrl = item.Id;
                            Konular.Add(makale);
                        }
                    }
                }
            }
            Konular = Konular.Take(5).ToList();
        }
Exemple #15
0
        public ArticlesModel Update(ArticlesModel article)
        {
            var query = "UPDATE Articles SET Title=@Title,Body=@Body,Image=@Image,Attachment=@Attachment WHERE Id=@Id";

            this.con.Execute(query, article);
            return(article);
        }
        public override Task <ModuleViewComponentResult> OnViewComponentUpdate()
        {
            ArticlesModel model = new ArticlesModel(this);

            model.Articles = _articleBusiness.GetArticlesList(Module.ModuleId).OrderByDescending(a => a.ArticleOrder).ToList();
            model.PageId   = Page.PageId;

            return(Task.FromResult(ModuleView("Settings", model)));
        }
Exemple #17
0
        public async Task <ActionResult> SaveItem(Articles data)
        {
            ArticlesModel model = new ArticlesModel()
            {
                Item = data
            };
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + HttpContext.Request.Headers["UserName"];
            int    IdDC           = Int32.Parse(MyModels.Decode(model.Item.Ids, API.Models.Settings.SecretId + ControllerName).ToString());

            if (ModelState.IsValid)
            {
                if (data.Alias == null || data.Alias == "")
                {
                    model.Item.Alias = API.Models.MyHelper.StringHelper.UrlFriendly(data.Title);
                }
                if (model.Item.Icon != null)
                {
                    var Image = await FileHelpers.ProcessFormFile(model.Item.Icon, ModelState);

                    if (Image.Length > 0)
                    {
                        model.Item.Images = Image;
                    }
                }
                if (model.Item.Id == IdDC)
                {
                    model.Item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.Item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.Item.IdCoQuan   = int.Parse(HttpContext.Request.Headers["IdCoQuan"]);
                    try
                    {
                        ArticlesService.SaveItem(model.Item);
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                        string Str_Url = HttpContext.Session.GetString("STR_Action_Link_" + ControllerName);
                        if (Str_Url != null && Str_Url != "")
                        {
                            return(Redirect("/Admin/" + this.ControllerContext.RouteData.Values["controller"].ToString() + "/Index" + Str_Url));
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    catch
                    {
                    }
                }
            }
            model.SearchData = new SearchArticles()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            model.ListItemsDanhMuc = CategoriesArticlesService.GetListItems();
            model.ListItemsAuthors = API.Areas.Admin.Models.USUsers.USUsersService.GetListItemsAuthor(4);
            model.ListItemType     = ArticlesService.GetListItemsType();
            return(View(model));
        }
Exemple #18
0
        public IActionResult Update(ArticlesModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Update"));
            }

            _articleService.UpdateArticle(model);
            return(RedirectToAction("ArticlesTable"));
        }
Exemple #19
0
        public string Add(ArticlesModel article)
        {
            string query = "INSERT INTO Articles(Title,Body,Image,Attachment)"
                           + "VALUES(@Title,@Body,@Image,@Attachment)";

            con.Execute(query, new { article.Title, article.Body, article.Image, article.Attachment });
            string result = "Article Added";

            return(result);
        }
Exemple #20
0
        public void GetClientArticleSuccess(ArticlesModel model)
        {
            handler.Post(() =>
            {
                article          = model;
                txtTitle.Text    = article.Title;
                txtAuthor.Text   = Html.FromHtml(article.Author).ToString();
                txtPostdate.Text = DateTimeUtils.CommonTime(article.PostDate);

                if (article.DiggCount > 0)
                {
                    txtDigg.Text = article.DiggCount.ToString();
                }
                if (article.ViewCount > 0)
                {
                    txtRead.Text = article.ViewCount.ToString();
                }
                if (article.CommentCount > 0)
                {
                    txtComments.Text = article.CommentCount.ToString();
                }
                (txtComments.Parent as FrameLayout).Click += delegate
                {
                    ArticleCommentsActivity.Start(this, article.BlogApp, article.Id);
                };
                (txtBookmark.Parent as FrameLayout).Click += delegate
                {
                    var linkurl = article.Url;
                    var title   = article.Title + " - " + article.Author + " - ²©¿ÍÔ°";
                    BookmarkAddActivity.Start(this, linkurl, title, true);
                };

                if (article.Body == null || article.Body == "")
                {
                    OnRefresh();
                }
                else
                {
                    GetServiceArticleSuccess(model);
                }
                try
                {
                    Picasso.With(this)
                    .Load(article.Avatar)
                    .Placeholder(Resource.Drawable.placeholder)
                    .Error(Resource.Drawable.placeholder)
                    .Transform(new CircleTransform())
                    .Into(imgAvatar);
                }
                catch (Exception)
                {
                }
            });
        }
Exemple #21
0
        public IActionResult ViewLog(string Id = null)
        {
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + HttpContext.Request.Headers["UserName"];
            ArticlesModel data           = new ArticlesModel()
            {
            };
            int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.ListItems = ArticlesService.GetListLogArticles(IdDC, API.Models.Settings.SecretId + ControllerName);
            return(View(data));
        }
        public async Task <IActionResult> PutArticles(int id, ArticlesModel articlesModel)
        {
            if (id != articlesModel.ArticleId)
            {
                return(BadRequest());
            }

            var articles = new Articles()
            {
                ArticleId        = articlesModel.ArticleId,
                Name             = articlesModel.Name,
                HeroImage        = articlesModel.HeroImage,
                ShortDescription = articlesModel.ShortDescription,
                Description      = articlesModel.Description,
                PublicationDate  = articlesModel.PublicationDate,
                Category         = articlesModel.CategoryId
            };

            _context.Entry(articles).State = EntityState.Modified;

            var articleTags = _context.ArticlesTags.Where(s => s.ArticleId == articlesModel.ArticleId);

            _context.ArticlesTags.RemoveRange(articleTags);

            for (int i = 0; i < articlesModel.Tags.Length; i++)
            {
                var articleTag = new ArticlesTags()
                {
                    ArticleId = articles.ArticleId,
                    TagId     = _context.Tags.Where(name => name.TagName == articlesModel.Tags[i]).Select(s => s.TagId).First()
                };

                _context.ArticlesTags.Add(articleTag);
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ArticlesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #23
0
        //Dohvaćanje iz baze podataka
        public async Task <ActionResult> Index()
        {
            var client = new MongoClient("mongodb://localhost");

            database = client.GetDatabase("portal");
            var articlesCol = database.GetCollection <Article>("vijesti");
            var output      = await articlesCol.Find(Builders <Article> .Filter.Empty).Sort(Builders <Article> .Sort.Descending("_id")).Limit(10).ToListAsync();

            ArticlesModel articles = new ArticlesModel();

            articles.Articles = output;
            return(View(articles));
        }
Exemple #24
0
        /// <summary>
        ///  回复扫码推事件且弹出“消息接收中”提示框消息
        /// </summary>
        /// <param name="model">The model.</param>
        /// Author  : 俞立钢
        /// Company : 绍兴标点电子技术有限公司
        /// Created : 2014-10-13 16:09:53
        public static void ReplyScanCodeWaitmsg(Dictionary <string, string> model)
        {
            string value = model.ReadKey("ScanCodeInfo");

            /*string content = string.Format("项目编号:{0};\n验收状态:{1};\n验收结果:{2};\n报表查看:<a href='{3}'>点击查看</a>", value.Substring(6), "完成", "通过", "http://www.sxajj.gov.cn/1.jpg");
             * ProduceText(model, content);*/
            List <ArticlesModel> articles = new List <ArticlesModel>();

            for (int i = 0; i < 2; i++)
            {
                ArticlesModel article = new ArticlesModel();
            }
        }
        public ArticlesModel Index()
        {
            var articles = _articlesRepository.GetAllArticles();

            var map           = AutoMapper.Mapper.CreateMap <IArticle, Article>();
            var articleModels = articles.Select(AutoMapper.Mapper.Map <Article>);

            var model = new ArticlesModel
            {
                Articles = articleModels
            };

            return(model);
        }
        public ActionResult ShowAllArticles()
        {
            var articles = _articlesRepository.GetAllArticles();

            var map           = AutoMapper.Mapper.CreateMap <IArticle, Article>();
            var articleModels = articles.Select(AutoMapper.Mapper.Map <Article>);

            var model = new ArticlesModel
            {
                Articles = articleModels
            };

            return(View("~/Views/Partials/ArticlesListingView.cshtml", model));
        }
Exemple #27
0
 public ActionResult Edit(int id, ArticlesModel Article)
 {
     try
     {
         // TODO: Add update logic here
         ArticlesRepository ArticleRepo = new ArticlesRepository();
         ArticleRepo.Update(Article);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemple #28
0
        private async Task <ArticlesModel> SetArticleComment(ArticleCommentViewModel comment)
        {
            ArticlesModel articlecomment = new ArticlesModel();
            var           article        = await GetArticle(comment.ArticleId);

            var comments = await GetComments(comment.ArticleId);

            articlecomment.ArticleViewModel       = article;
            articlecomment.lstArticleCommentModel = comments;

            articlecomment.ArticleCommentModel = comment;

            return(articlecomment);
        }
Exemple #29
0
 public void GetServiceArticleSuccess(ArticlesModel model)
 {
     handler.Post(() =>
     {
         article = model;
         if (swipeRefreshLayout.Refreshing)
         {
             swipeRefreshLayout.Refreshing = false;
         }
         var content = HtmlUtils.ReadHtml(Assets);
         var body    = HtmlUtils.ReplaceHtml(model.Body).Trim('"');
         txtBody.LoadDataWithBaseURL("file:///android_asset/", content.Replace("#title#", "").Replace("#body#", body), "text/html", "utf-8", null);
     });
 }
Exemple #30
0
//		[Route("/Home/Index")]
//		[HttpGet]
        public IActionResult Index()
        {
            ArticlesModel  model      = new ArticlesModel();
            List <Article> list       = model.Articles().ToList();
            IndexModel     indexModel = new IndexModel();

/*
 *                      foreach (Article article in list)
 *                      {
 *                              indexModel.articles.Add(article);
 *                      }
 */
            return(View("Index", list));
        }
Exemple #31
0
        public void WeChatTest()
        {
            sNews m=new sNews();
            m.FromUserName = ReadXml.ReadModel("FromUserName",model);
            m.ToUserName = ReadXml.ReadModel("ToUserName", model);
            m.CreateTime = long.Parse(ReadXml.ReadModel("CreateTime", model));
            m.MsgType = "news";

            m.ArticleCount = 5;
            List<ArticlesModel> listNews=new List<ArticlesModel>();
            for (int i = 0; i < 6; i++)
            {
                ArticlesModel ma=new ArticlesModel();
                ma.Title = "";

            }
        }