// GET: Admin/CMSCategories
        public ActionResult Index()
        {
            CMS_ProductsModels model = new CMS_ProductsModels();

            try
            {
                var _Key        = Request["keywordID"] ?? "";
                var _Group      = Request["GroupID"] ?? "";
                var FilterModel = new PinFilterDTO();
                FilterModel.PageIndex = Commons.PageIndex;
                FilterModel.PageSize  = Commons.PageSize;
                FilterModel.TypeTime  = Commons.ESortType1.TimeCreatedAtDecrease.ToString("d");
                model.TypeTime        = int.Parse(Commons.ESortType1.TimeCreatedAtDecrease.ToString("d"));
                FilterModel.Sort1     = (byte)Commons.ESortType1.TimeCreatedAtDecrease;
                model.Sort1           = (byte)Commons.ESortType1.TimeCreatedAtDecrease;
                FilterModel.Sort2     = (byte)Commons.ESortType2.ReactionDecrease;
                model.Sort2           = (byte)Commons.ESortType2.ReactionDecrease;
                model.Index           = int.Parse(Commons.EIndex.LikeReduce.ToString("d"));
                #region "Comment"
                //if (Request.Cookies["FromDate"] != null)
                //{
                //    var _FromDate = Convert.ToDateTime(Request.Cookies["FromDate"].Value);
                //    FilterModel.CreatedAtFrom = _FromDate;
                //}
                //if(Request.Cookies["ToDate"] != null)
                //{
                //    var _ToDate = Convert.ToDateTime(Request.Cookies["ToDate"].Value);
                //    FilterModel.CreatedAtTo = _ToDate;
                //}
                //string TypeTime = "", TypePin = "";
                //if (Request.Cookies["TypeTime"] != null)
                //{
                //    TypeTime = Request.Cookies["TypeTime"].Value;
                //    model.TypeTime = Convert.ToInt16(TypeTime);
                //}
                //if (Request.Cookies["TypePin"] != null)
                //{
                //    TypePin = Request.Cookies["TypePin"].Value;
                //    model.TypePin = Convert.ToInt16(TypePin);
                //}

                //if (Request.Cookies["TypeQuantity"] != null)
                //{
                //    var RepinCount = Request.Cookies["TypeQuantity"].Value.ToString();
                //    if(RepinCount == Commons.EQuantityType.ZeroToOne.ToString("d"))
                //    {
                //        FilterModel.PinCountFrom = 0;
                //        FilterModel.PinCountTo = 100;
                //    }

                //    if (RepinCount == Commons.EQuantityType.OneToTwo.ToString("d"))
                //    {
                //        FilterModel.PinCountFrom = 100;
                //        FilterModel.PinCountTo = 200;
                //    }
                //    if (RepinCount == Commons.EQuantityType.TwoToThree.ToString("d"))
                //    {
                //        FilterModel.PinCountFrom = 200;
                //        FilterModel.PinCountTo = 300;
                //    }
                //    if (RepinCount == Commons.EQuantityType.ThreeToFour.ToString("d"))
                //    {
                //        FilterModel.PinCountFrom = 300;
                //        FilterModel.PinCountTo = 400;
                //    }
                //    if (RepinCount == Commons.EQuantityType.FourToFive.ToString("d"))
                //    {
                //        FilterModel.PinCountFrom = 400;
                //        FilterModel.PinCountTo = 500;
                //    }
                //    if (RepinCount == Commons.EQuantityType.MoreFive.ToString("d"))
                //    {
                //        FilterModel.PinCountFrom = 500;
                //    }
                //    model.TypeQuantity = Convert.ToInt16(RepinCount);
                //}

                //if(Request.Cookies["Keywords"] != null)
                //{
                //    var Keywords = Request.Cookies["Keywords"].Value;
                //    char[] separator = new char[] { ',' };
                //    var ListKeyword = CommonHelper.ParseStringToList(Keywords, separator);
                //    FilterModel.lstKeyWordID = ListKeyword;
                //    model.listKeywords = ListKeyword;
                //}
                #endregion
                model.ListTime     = getListTime();
                model.ListQuantity = getListQuantity();
                model.ListIndex    = getListIndex();
                model.ListSort2    = getListSort2();
                // model.ListRePin = getListRepinCount();
                ViewBag.Keywords         = getListKeyword();
                ViewBag.ListGroupFanpage = getListGroupKeyword();
                if (!string.IsNullOrEmpty(_Key))
                {
                    FilterModel.LstKeyWordID.Add(_Key);
                    model.listKeywords.Add(_Key);
                }
                if (!string.IsNullOrEmpty(_Group))
                {
                    FilterModel.LstGroupID.Add(_Group);

                    var _lstKeywords = getListKeyWordByGroup(_Group);
                    model.listKeywords.AddRange(_lstKeywords);
                }

                var _pinModels = new List <PinsModels>();
                var msg        = "";
                int totalPin   = 0;
                var result     = _fac.GetPin(ref _pinModels, ref totalPin, FilterModel, ref msg);
                if (result)
                {
                    model.Crawler.Pins = _pinModels.OrderBy(x => x.Created_At).ToList();
                    #region "Comment"
                    //if (TypeTime.Equals(Commons.ETimeType.TimeReduce.ToString("d")))
                    //{
                    //    model.Crawler.Pins = model.Crawler.Pins.OrderByDescending(x => x.Created_At).ToList();
                    //}
                    //else if (TypeTime.Equals(Commons.ETimeType.TimeIncrease.ToString("d")))
                    //{
                    //    model.Crawler.Pins = model.Crawler.Pins.OrderBy(x => x.Created_At).ToList();
                    //}
                    //else if (TypePin.Equals(Commons.ETimeType.PinReduce.ToString("d")))
                    //{
                    //    model.Crawler.Pins = model.Crawler.Pins.OrderByDescending(x => x.Repin_count).ToList();
                    //}
                    //else if (TypePin.Equals(Commons.ETimeType.PinIncrease.ToString("d")))
                    //{
                    //    model.Crawler.Pins = model.Crawler.Pins.OrderBy(x => x.Repin_count).ToList();
                    //}
                    #endregion
                }
            }
            catch (Exception ex)
            {
            }
            return(View(model));
        }
        // GET: Admin/CMSCategories
        public ActionResult Index()
        {
            CMS_ProductsModels model = new CMS_ProductsModels();

            try
            {
                var _Key        = Request["BoardID"] ?? "";
                var _Group      = Request["GroupID"] ?? "";
                var FilterModel = new PinFilterDTO();
                FilterModel.PageIndex = Commons.PageIndex;
                FilterModel.PageSize  = Commons.PageSize;
                FilterModel.TypeTime  = Commons.ETimeType.TimeReduce.ToString("d");
                model.ListTime        = getListTime();
                model.ListQuantity    = getListQuantity();
                // model.ListRePin = getListRepinCount();
                var lstBoard = getListBoard();
                ViewBag.Keywords = lstBoard;
                if (!string.IsNullOrEmpty(_Key))
                {
                    FilterModel.LstBoardID.Add(_Key);
                    model.listBoards.Add(_Key);
                }
                if (!string.IsNullOrEmpty(_Group))
                {
                    FilterModel.LstGroupBoardID.Add(_Group);

                    var _lstKeywords = getListBoardByGroud(_Group);
                    FilterModel.LstBoardID = _lstKeywords;
                    model.listBoards.AddRange(_lstKeywords);
                }

                if (FilterModel.LstBoardID.Count == 0)
                {
                    FilterModel.LstBoardID = lstBoard.Select(o => o.Value).ToList();
                }

                if (FilterModel.LstBoardID != null && FilterModel.LstBoardID.Count > 0)
                {
                    var _pinModels = new List <PinsModels>();
                    var msg        = "";
                    int totalPin   = 0;
                    var result     = _fac.GetPin(ref _pinModels, ref totalPin, FilterModel, ref msg);
                    if (result)
                    {
                        model.Crawler.Pins = _pinModels.OrderBy(x => x.Created_At).ToList();
                        #region "Comment"
                        //if (TypeTime.Equals(Commons.ETimeType.TimeReduce.ToString("d")))
                        //{
                        //    model.Crawler.Pins = model.Crawler.Pins.OrderByDescending(x => x.Created_At).ToList();
                        //}
                        //else if (TypeTime.Equals(Commons.ETimeType.TimeIncrease.ToString("d")))
                        //{
                        //    model.Crawler.Pins = model.Crawler.Pins.OrderBy(x => x.Created_At).ToList();
                        //}
                        //else if (TypePin.Equals(Commons.ETimeType.PinReduce.ToString("d")))
                        //{
                        //    model.Crawler.Pins = model.Crawler.Pins.OrderByDescending(x => x.Repin_count).ToList();
                        //}
                        //else if (TypePin.Equals(Commons.ETimeType.PinIncrease.ToString("d")))
                        //{
                        //    model.Crawler.Pins = model.Crawler.Pins.OrderBy(x => x.Repin_count).ToList();
                        //}
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(View(model));
        }