Esempio n. 1
0
        public ActionResult PageNews(int page = 1, int pagesize = 5)
        {
            var dao = new NewsDao();
            var i   = dao.ListAllPageNews(page, pagesize);

            return(View(i));
        }
Esempio n. 2
0
        public ActionResult Tag(string tagId, int page = 1, int pageSize = 10)
        {
            ViewBag.Tags = tagId;
            //CategoryDao ctDao = new CategoryDao();

            //ViewBag.Cate = ctDao.FindByID(cateId);
            //var items = GetClientCategoryViewModel();
            //ViewBag.CatePare = items.Find(x => x.ID == cateId);

            var model       = new NewsDao().ListAllByTag(tagId, page, pageSize);
            int totalRecord = new NewsDao().ListAllByTagCount(tagId);

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;

            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((double)(totalRecord / pageSize)) + 1;
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;
            return(View(model));
        }
Esempio n. 3
0
        public ActionResult Detail(long id)
        {
            var tt = new NewsDao().ViewDetail(id);

            ViewBag.SameNews = new NewsDao().ListSameNews(id);
            return(View(tt));
        }
Esempio n. 4
0
        public ActionResult Detail(long ID)
        {
            ViewBag.Tags = Session["tag"];
            ViewBag.Cate = null;
            if (Session["tag"] == null)
            {
                var catID = Convert.ToInt64(Session["CategoryID"]);

                CategoryDao ctDao = new CategoryDao();
                ViewBag.Cate = ctDao.FindByID(catID);
                var items = GetClientCategoryViewModel();
                ViewBag.CatePare = items.Find(x => x.ID == catID);
            }
            else
            {
                ViewBag.Tags = Session["tag"];
            }


            NewsDao nDao   = new NewsDao();
            News    objNew = nDao.FindByID(ID);

            objNew.ViewCount = objNew.ViewCount + 1;
            nDao.Update(objNew);
            return(View(objNew));
        }
Esempio n. 5
0
        public PartialViewResult EventsPartial()

        {
            NewsDao dbDao = new NewsDao();

            return(PartialView(dbDao.ListTag()));
        }
Esempio n. 6
0
        public ActionResult Delete(long id)
        {
            try
            {
                // TODO: Add delete logic here

                CategoryDao bdDao    = new CategoryDao();
                NewsDao     dbNewDao = new NewsDao();

                if (bdDao.FindChildCategory(id).Count > 0)
                {
                    SetAlert("Đang sử dụng không được phép xóa", SystemConsts.ALERT_DANGER);
                    return(RedirectToAction("Index"));
                }
                if (dbNewDao.ToActiveByCateID(id).Count > 0)
                {
                    SetAlert("Đang sử dụng không được phép xóa", SystemConsts.ALERT_DANGER);
                    return(RedirectToAction("Index"));
                }
                bdDao.Delete(id);
                // SetAlert("Xóa thành công", "success");
                return(RedirectToAction("Index"));
            }
            catch
            {
                // SetAlert("Không xóa được", "danger");
                return(View());
            }
        }
Esempio n. 7
0
        public async Task <ActionResult <UULResponse> > GetNews(int id)
        {
            UULResponse response;
            var         currentUser = HttpContext.User;

            try {
                var auditory = Auditory.GUESTS;
                if (currentUser.Identity.IsAuthenticated)
                {
                    auditory = (await UserDao.GetUserFromClaimsOrThrow(_context, currentUser)).IsActivated ? Auditory.ACTIVATED : Auditory.REGISTERED;
                }
                var newsDTO = await NewsDao.GetNewsByIdAsync(_context, auditory, id);

                response = new UULResponse()
                {
                    Success = true, Message = "News item", Data = new NewsWebDTO(newsDTO)
                };
            } catch (Exception e) {
                response = new UULResponse()
                {
                    Success = false, Message = e.Message, Data = null
                };
            }
            return(response);
        }
Esempio n. 8
0
        // GET: Admin/News
        public ActionResult Index(string SearchTittle = null, int page = 1, int pageSize = 10)
        {
            var news = new NewsDao().GetNews(SearchTittle, page, pageSize);

            ViewBag.SearchTittle = SearchTittle;
            return(View(news));
        }
Esempio n. 9
0
        // GET: News
        public ActionResult Index()
        {
            var productDao = new NewsDao();

            ViewBag.News = productDao.ListNew(5);
            return(View());
        }
Esempio n. 10
0
        // GET: Admin/News
        public ActionResult Index(string searchstring, int page = 1, int pageSize = 10)
        {
            var dao   = new NewsDao();
            var model = dao.ListAllPaging(searchstring, page, pageSize);

            return(View(model));
        }
Esempio n. 11
0
        private void Add()
        {
            NewsInfo model = new NewsInfo();

            model.ID         = int.Parse(Request.Form["ID"]);
            model.CategoryID = int.Parse(Request.Form["CategoryID"]);
            model.Title      = Request.Form["Title"];
            if (Request.Form["Release_time"].Trim() == "")
            {
                model.Release_time = DateTime.Now;
            }
            else
            {
                model.Release_time = Convert.ToDateTime(Request.Form["Release_time"]);
            }
            model.Release_people = Request.Form["Release_people"];
            model.Click          = int.Parse(Request.Form["Click"]);
            model.IsHost         = Convert.ToBoolean(Request.Form["IsHost"]);
            model.State          = Convert.ToBoolean(Request.Form["State"]);

            //大文本处理

            int id = dao.Add(model);

            /////////////////////

            NewsDao.AddGive(id);

            Log.WritePage(id > 0 ? "SUCCESS" : "Error");
        }
Esempio n. 12
0
        public ActionResult AddNews(NewsModel NewsModel)
        {
            var Newsdao = new NewsDao();
            var News    = new NEWS();

            if (ModelState.IsValid)//kiem tra xem form co rong hay khong
            {
                News.newsTitle   = NewsModel.newsTitle;
                News.newsImg     = NewsModel.newsImg;
                News.newsContent = NewsModel.newsContent;
                News.newsType    = NewsModel.newsType;


                long id = Newsdao.AddNews(News);
                if (id < 0)
                {
                    ModelState.AddModelError("", "Thêm thất bại");
                    return(RedirectToAction("AddNews", "News"));
                }
                else
                {
                    ViewData["success"] = "Thêm News thành công";
                }
            }
            return(View());
        }
Esempio n. 13
0
        public ActionResult NewsTag(string tagId)
        {
            var news = new NewsDao().ListAllByTag(tagId);

            ViewBag.ListTag = new NewsDao().GetTag(tagId);
            return(View(news));
        }
Esempio n. 14
0
        public ActionResult Detail(long id)
        {
            var news = new NewsDao().ViewDetail(id);

            ViewBag.Product = new CategoryDao().ViewDetail(news.ProductID.Value);
            return(View(news));
        }
Esempio n. 15
0
        public ActionResult Index(int pageIndex = 1, int pageSize = 9)
        {
            var model       = new NewsDao().ListAll();
            int totalRecord = model.Count();

            //Lấy 1 khoảng trong list sản phẩm từ pageIndex đến pageSize để phân trang
            model = model.Skip((pageIndex - 1) * pageSize)
                    .Take(pageSize);
            //Đếm lấy số record thực tế ở đoạn record hiện tại
            int totalRowCurent = model.Count();

            //Các biến để phân trang
            ViewBag.totalRecord = totalRecord;
            ViewBag.pageIndex   = pageIndex;
            int recordStartPosition = ((pageIndex - 1) * pageSize) + 1;
            int recordEndPosition   = ((recordStartPosition - 1 + pageSize) < totalRecord) ? (recordStartPosition - 1 + pageSize) : recordStartPosition - 1 + totalRowCurent;

            ViewBag.recordStartPosition = recordStartPosition;
            ViewBag.recordEndPosition   = recordEndPosition;
            int maxPage   = 5;
            int totalPage = (int)Math.Ceiling((double)(totalRecord / pageSize));

            if (totalRecord % pageSize > 0 && totalRecord > pageSize)
            {
                totalPage += 1;
            }
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = pageIndex + 1;
            ViewBag.Prev      = pageIndex - 1;
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            return(View(model));
        }
Esempio n. 16
0
        public ActionResult Publicer(FormCollection data)
        {
            try
            {
                NewsDao bdDao = new NewsDao();
                News    bd    = bdDao.FindByID(Convert.ToInt64(data["NewsID"].ToString()));


                UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION];

                bd.ModifiedBy = us.UserName;

                bd.ModifiedDate  = Hepper.GetDateServer();
                bd.PublishedDate = Hepper.GetDateServer();
                int Status = Convert.ToInt32(data["Status"]);
                bd.Status      = Status;
                bd.ContentHtml = data["ContentHtml"].ToString();
                if (bdDao.Update(bd) > 0)
                {
                    SetAlert(@Resources.ResourceAdmin.AdminEditRecordSucess, "success");
                    return(RedirectToAction("Index"));
                }
                else
                {
                    SetAlert(@Resources.ResourceAdmin.AdminEditRecordFailed, "danger");
                }
            }
            catch
            {
                ModelState.AddModelError("", Resources.ResourceAdmin.ErrorGetRecordMessage);
            }
            return(View());
        }
Esempio n. 17
0
        /// <summary>
        /// 获取新闻内容
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static List <NewsModel> GetBaiduNewsContent(string url)
        {
            //请求响应

            var httpContent = WebUtil.GetHttpContent(url);
            //获取新闻标题列表
            var regex =
                "<ahref=\\S+mon=(\"ct=[0-9]&a=[0-9]&c=top&pn=[0-9]+\"|\"ct=[0-9]&amp;a=[0-9]&amp;c=top&pn=[0-9]+\"" +
                "|\"r=[0-9]\")(\\S*)>\\S+</a>";
            var newsList = HtmlUtil.StripHTML(httpContent, regex);
            var listData = new List <NewsModel>();

            //将数据保存到MongoDb中
            foreach (var news in newsList)
            {
                var model = new NewsModel()
                {
                    NewsTitle  = news,
                    CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    UpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                };
                listData.Add(model);
            }

            NewsDao.InsertToMongo(listData);
            return(listData);
        }
Esempio n. 18
0
        public ActionResult Delete(int id)
        {
            var dao = new NewsDao();

            dao.Delete(id);
            return(RedirectToAction("Index"));
        }
Esempio n. 19
0
        public ActionResult Edit(int id)
        {
            var News = new NewsDao().Viewdetail(id);

            ViewBag.type = News.newsType;
            return(View(News));
        }
Esempio n. 20
0
        public ActionResult Index(int page = 1, int pageSize = 5)
        {
            var dao   = new NewsDao();
            var model = dao.ListAllPaging(page, pageSize);

            return(View(model));
        }
Esempio n. 21
0
        public async Task <ActionResult <UULResponse> > GetNews()
        {
            UULResponse response;
            var         currentUser = HttpContext.User;

            try {
                var auditory = Auditory.GUESTS;
                if (currentUser.Identity.IsAuthenticated)
                {
                    var user = (await UserDao.GetUserFromClaimsOrDefault(_context, currentUser));
                    if (user == null)
                    {
                        return(Error.ProfileNotFound.CreateErrorResponse(_logger, "GetNews"));
                    }
                    auditory = user.IsActivated ? Auditory.ACTIVATED : Auditory.REGISTERED;
                }
                var newsListDTO = await NewsDao.GetNewsAsync(_context, auditory);

                response = new UULResponse()
                {
                    Success = true, Message = "News list", Data = new NewsPaperDTO()
                    {
                        News = newsListDTO.Select(n => new NewsDTO(n)).ToList()
                    }
                };
            } catch (Exception e) {
                response = Error.NewsGetFailed.CreateErrorResponse(_logger, "GetNews", e);
            }
            return(response);
        }
Esempio n. 22
0
        public ActionResult Category(long cateId, int page = 1, int pageSize = 10)
        {
            CategoryDao ctDao = new CategoryDao();

            ViewBag.Cate = ctDao.FindByID(cateId);

            var items = GetClientCategoryViewModel();

            ViewBag.CatePare = items.Find(x => x.ID == cateId);

            var model       = new NewsDao().ListtiveByCateIDPaging(cateId, page, pageSize);
            int totalRecord = new NewsDao().ToActiveByCateID(cateId).Count();

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;

            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((double)(totalRecord / pageSize)) + 1;
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;
            return(View(model));
        }
Esempio n. 23
0
        public ActionResult Edit(int id)
        {
            var news = new NewsDao().ViewDetail(id);

            SetViewBagProduct(news.ProductID);
            SetViewBagCity(news.CityID);
            return(View(news));
        }
Esempio n. 24
0
        // GET: Admin/Category

        public ActionResult Index()
        {
            NewsDao bdDao = new NewsDao();

            ViewBag.lstCate = GetClientCategoryViewModel();
            //TempData["AlertMessage"] = null;
            return(View(bdDao.ToList()));
        }
Esempio n. 25
0
        // GET: Admin/News
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var dao    = new NewsDao();
            var tintin = dao.ListAllPaging(searchString, page, pageSize);

            ViewBag.SearchString = searchString;
            return(View(tintin));
        }
Esempio n. 26
0
        // GET: News
        public ActionResult Index(string searchString, int page = 1, int pageSize = 5)
        {
            var dao   = new NewsDao();
            var model = dao.LissAllPaging(searchString, page, pageSize);

            ViewBag.searchString = searchString;
            return(View(model));
        }
Esempio n. 27
0
        public ActionResult Edit(long id)
        {
            ViewBag.MenuActive = "mIndexNews";
            var entity = new NewsDao().GetByID(id);

            SetDropdownList(entity.NewsCategoryID);
            return(View(entity));
        }
Esempio n. 28
0
        public ActionResult Update(int id)
        {
            var dao  = new NewsDao();
            var item = dao.GetNewsById(id);

            SetViewBag(item.NewsType);
            return(View());
        }
Esempio n. 29
0
        public ActionResult Newslist(string searchString, int page = 1, int pageSize = 10)
        {
            var dao   = new NewsDao();
            var model = dao.ListAllNews(searchString, page, pageSize);

            ViewBag.searchString = searchString;;
            return(View(model));
        }
Esempio n. 30
0
        public JsonResult ChangeStatus(long id)
        {
            var res = new NewsDao().ChangeStatus(id);

            return(Json(new
            {
                status = res
            }));
        }