Beispiel #1
0
        public IEnumerable <TblNews> GetListNewsAll()
        {
            ManageNewsDa          dataAccess = new ManageNewsDa();
            IEnumerable <TblNews> results    = dataAccess.GetListNewsAll();

            return(results);
        }
Beispiel #2
0
        public bool DeleteNews(long NEWS_ID = 0)
        {
            ManageNewsDa dataAccess = new ManageNewsDa();

            long result = 0;

            using (var transaction = new TransactionScope())
            {
                try
                {
                    result = dataAccess.DeleteNews(NEWS_ID);

                    if (result > 0)
                    {
                        transaction.Complete();
                    }
                }
                catch (Exception ex)
                {
                    transaction.Dispose();
                    result = -1;
                    throw new Exception(ex.Message, ex);
                }
                finally
                {
                    transaction.Dispose();
                }
            }

            return(result > 0);
        }
Beispiel #3
0
        public IEnumerable <TblNews> GetListNews(int maxItem = 0)
        {
            ManageNewsDa          dataAccess = new ManageNewsDa();
            IEnumerable <TblNews> results    = dataAccess.GetListNews(maxItem);

            return(results);
        }
Beispiel #4
0
        public long UpdateNews(TblNews model)
        {
            long res = 0;
            // Declare new DataAccess object
            ManageNewsDa dataAccess = new ManageNewsDa();

            using (var transaction = new TransactionScope())
            {
                try
                {
                    model.MetaTitle = model.Name.Contains("/") ? model.Name.Replace("/", "") : model.Name;
                    model.MetaTitle = UtilityServices.UtilityServices.ConvertToUnsign(model.MetaTitle);
                    res             = dataAccess.UpdateNews(model);

                    if (res <= 0)
                    {
                        transaction.Dispose();
                    }
                    transaction.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message, ex);
                }
                finally
                {
                    transaction.Dispose();
                }
            }
            return(res);
        }
Beispiel #5
0
        public IEnumerable <NewsModel> SearchNewsList(DataTableModel dt, NewsModel model, out int total_row)
        {
            ManageNewsDa            dataAccess = new ManageNewsDa();
            IEnumerable <NewsModel> results    = dataAccess.SearchNewsList(dt, model, out total_row);

            return(results);
        }
        // GET: ManageNews
        #region REGISTER/ UPDATE
        public ActionResult NewsEdit(long newsId = 0)
        {
            CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel;

            if (currentUser == null || currentUser.IsAdmin == false)
            {
                return(RedirectToAction("Login", "Login"));
            }

            TblNews       model      = new TblNews();
            CommonService comService = new CommonService();
            ManageNewsDa  dataAccess = new ManageNewsDa();

            model.Status = Constant.Status.ACTIVE;

            if (newsId > 0)
            {
                TblNews infor = new TblNews();
                infor         = dataAccess.getInfoNews(newsId);
                model         = infor != null ? infor : model;
                model.Content = HttpUtility.HtmlDecode(model.Content);
            }

            return(View(model));
        }
        public ActionResult NewsDetail(long newsId = 0)
        {
            TblNews      model      = new TblNews();
            ManageNewsDa dataAccess = new ManageNewsDa();
            NewsService  service    = new NewsService();

            model.Status = Constant.Status.ACTIVE;

            if (newsId > 0)
            {
                TblNews infor = new TblNews();
                infor                = dataAccess.getInfoNews(newsId);
                model                = infor != null ? infor : model;
                model.Content        = HttpUtility.HtmlDecode(model.Content);
                @ViewBag.listNewMore = service.GetListNews(10);
            }

            return(View(model));
        }
        public ActionResult NewsList()
        {
            CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel;

            if (currentUser == null || currentUser.IsAdmin == false)
            {
                return(RedirectToAction("Login", "Login"));
            }

            NewsModel model = new NewsModel();

            CommonService comService = new CommonService();
            ManageNewsDa  dataAccess = new ManageNewsDa();

            var tmpCondition = GetRestoreData() as NewsModel;

            if (tmpCondition != null)
            {
                model = tmpCondition;
            }

            return(View(model));
        }