private WebNews SetWebNews(WebNews item, WebCategory category)
 {
     item.NewsId = SnowFlake.NewId;
     if (string.IsNullOrEmpty(item.CustomTitle) && !string.IsNullOrEmpty(item.NewsTitle))
     {
         item.CustomTitle = item.NewsTitle;
         item.NewsTitle   = "";
     }
     if (item.SpecialCode == "C0000")
     {
         item.SpecialCode = null;
     }
     item.CategoryId   = category.CategoryId;
     item.CategoryName = category.CategoryName;
     item.AccessNumber = 0;
     item.ClickNumber  = 0;
     item.AuditBy      = 1;
     item.AuditStatus  = 1;
     item.AuditTime    = item.PushTime;
     item.PushStatus   = 1;
     item.PushBy       = 1;
     item.OperateType  = 5;
     item.IsEnable     = 1;
     item.Remarks      = "管理员手动同步";
     item.CreateBy     = 1;
     item.CreateTime   = System.DateTime.Now;
     return(item);
 }
Exemple #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            WebCategory webCategory = db.Categories.Find(id);

            db.Categories.Remove(webCategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #3
0
 public ActionResult Edit([Bind(Include = "CategoryId,CategoryName,OrderNo,Status,UserId")] WebCategory webCategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(webCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.Administrators, "UserId", "UserName", webCategory.UserId);
     return(View(webCategory));
 }
Exemple #4
0
        // GET: Admin/WebCategories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WebCategory webCategory = db.Categories.Find(id);

            if (webCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(webCategory));
        }
Exemple #5
0
        // GET: Admin/WebCategories/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WebCategory webCategory = db.Categories.Find(id);

            if (webCategory == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserId = new SelectList(db.Administrators, "UserId", "UserName", webCategory.UserId);
            return(View(webCategory));
        }
        public async Task <ActionResult <Category> > PostCategory([FromBody] WebCategory category)
        {
            Category toPost = new Category
            {
                Name           = category.Name,
                ParentCategory = null,
            };
            int parentId = int.Parse(category.ParentCategoryId);

            try
            {
                var created = await categoriesService.PostCategory(toPost, category.ParentCategoryId);

                return(CreatedAtAction(nameof(GetCategory), new { id = created.ID }, created));
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(new { error = ex.Message }));
            }
        }
 public static WebCategory CreateWebCategory(int webID, int webCategoryID, int nestedLevel, int sortOrder)
 {
     WebCategory webCategory = new WebCategory();
     webCategory.WebID = webID;
     webCategory.WebCategoryID = webCategoryID;
     webCategory.NestedLevel = nestedLevel;
     webCategory.SortOrder = sortOrder;
     return webCategory;
 }
 public void AddToWebCategories(WebCategory webCategory)
 {
     base.AddObject("WebCategories", webCategory);
 }
Exemple #9
0
        private WebNews GetNewsEntity(WebCategory category, GatherPost x)
        {
            var entity = new WebNews();

            entity.NewsId       = SnowFlake.NewId;
            entity.CategoryId   = category.CategoryId;
            entity.CategoryName = category.CategoryName; //分类名称

            //entity.SiteId = x.site_id; //站点标识
            entity.SiteId = 1; //站点标识

            //entity.NewsTitle = x.title; //新闻标题
            entity.CustomTitle = x.title;                     //自定义标题

            entity.Contents = x.content;                      //内容

            entity.ContentType = x.content_type == 2 ? 2 : 1; //内容类型

            entity.Tags       = x.tag.Replace(',', '∮');      //标签
            entity.Source     = x.from;                       //来源
            entity.SourceLogo = x.from_pic;                   //来源Logo

            entity.Title       = x.title;                     //网页标题
            entity.Keywords    = x.search_word;               //网页关键字
            entity.Description = x.title;                     // 网页描述
            if (!string.IsNullOrEmpty(x.thumbpic))
            {
                if (entity.ContentType == 1)
                {
                    var thumbpic = x.thumbpic.Split(',');
                    for (var i = 0; i < thumbpic.Length; i++)
                    {
                        thumbpic[i] = thumbpic[i] + "?x-oss-process=style/xiaotu";
                    }
                    entity.ImageThums = string.Join('∮', thumbpic); // 缩略图
                                                                    // entity.ImagePaths = x.thumbpic.Replace(',', '∮'); // 大图由运维人员去设置
                }
                else if (entity.ContentType == 2)
                {
                    entity.ImageThums = x.thumbpic;
                    entity.ImagePaths = x.video;
                }
            }
            else if (!string.IsNullOrEmpty(x.video))
            {
                entity.ImageThums = x.thumbpic;
                entity.ImagePaths = x.video;
            }

            entity.Controller = "/Content";
            entity.Action     = "/Index";
            entity.Urls       = "/Content/Index";

            entity.Author       = "admin";
            entity.CategorySort = 255;
            entity.SpecialSort  = 255;
            entity.Sequence     = 255;

            entity.AuditBy     = 1; // 审核人
            entity.AuditStatus = 1; // 审核状态
            entity.AuditTime   = System.DateTime.Now;

            entity.IsEnable = 1;                      // 有效

            entity.PushBy     = 1;                    // 发布人
            entity.PushStatus = 1;                    // 已发布
            entity.PushTime   = System.DateTime.Now;  // 发布时间

            entity.OperateType = 4;                   //同步
            entity.CreateBy    = 1;                   //创建人
            entity.CreateTime  = System.DateTime.Now; //创建时间

            var codeNumber = new Random().Next(0, 12);

            if (codeNumber > 0)
            {
                entity.SpecialCode = string.Format("C{0:d4}", codeNumber); //
            }
            entity.DisplayType         = new Random().Next(0, 1);          //
            entity.IsHot               = new Random().Next(0, 1);          //
            entity.VirtualAccessNumber = new Random().Next(1000, 200000);  //

            entity.Duration = !x.duration.HasValue ? 0 : x.duration;       //视频时长
            entity.Remarks  = "PHP采集同步!";
            return(entity);
        }