Ejemplo n.º 1
0
        public ActionResult News()
        {
            shNewService        _tintuc = new shNewService();
            IEnumerable <shNew> dsNews  = _tintuc.DanhSachNews()
                                          .ToPagedList(1, 5);

            return(PartialView(dsNews));
        }
Ejemplo n.º 2
0
        public ActionResult NewsRelated(string NewGuiId)
        {
            shNewService        _tintuc = new shNewService();
            IEnumerable <shNew> dsNews  = _tintuc.DanhSachNews()
                                          .Where(x => x.NewGuiId != NewGuiId)
                                          .ToPagedList(1, 10);

            return(PartialView("NewsRelated", dsNews));
        }
Ejemplo n.º 3
0
        public ActionResult Details(int?id)
        {
            shNewService _tintuc = new shNewService();
            shNew        tintuc  = _tintuc.FindList().Where(x => x.NewId == id).FirstOrDefault();

            if (tintuc == null)
            {
                tintuc = new shNew();
            }



            return(View(tintuc));
        }
Ejemplo n.º 4
0
        public PartialViewResult ListNews(int?page)
        {
            int pageCurrent = 1;

            if (page.HasValue)
            {
                pageCurrent = page.Value;
            }

            shNewService _new = new shNewService();

            IPagedList <shNew> dsNews = _new.DanhSachNews_PhanTrang(pageCurrent, Config.PAGE_SIZE_10);

            ViewBag.ListNews = dsNews;
            return(PartialView("ListNews", dsNews));
        }
Ejemplo n.º 5
0
        public ActionResult DsNews(int?page)
        {
            int pageCurrent = 1;

            if (page.HasValue)
            {
                pageCurrent = page.Value;
            }

            shNewService _tintuc = new shNewService();

            IPagedList <shNew> dsNew = _tintuc.DanhSachNews_PhanTrang(pageCurrent, Config.PAGE_SIZE_9);

            ViewBag.DsNews = dsNew;

            return(PartialView("DsNews", ViewBag.DsNews));
        }
Ejemplo n.º 6
0
        public ActionResult Create(string id)
        {
            if (!string.IsNullOrWhiteSpace(id))
            {
                shNewService _new   = new shNewService();
                shNew        tintuc = _new.FindByKey(id);

                if (tintuc != null)
                {
                    return(View(tintuc));
                }
                else
                {
                    return(View(new shNew()));
                }
            }

            return(View(new shNew()));
        }
Ejemplo n.º 7
0
        public IEnumerable <TimKiemNangCao> TimKiemNangCao(string keyword)
        {
            List <TimKiemNangCao> ds      = new List <TimKiemNangCao>();
            TimKiemNangCao        timkiem = new TimKiemNangCao();

            // 1. Tìm kiếm trong bảng sản phẩm
            shProductService        _product  = new shProductService();
            IEnumerable <shProduct> dsProduct = _product.FindList().Where(x => TypeHelper.CompareString(x.ProductName, keyword));

            foreach (var product in dsProduct)
            {
                timkiem             = new TimKiemNangCao();
                timkiem.CategoryId  = TheLoaiTimKiemNangCao.SanPham.GetHashCode();
                timkiem.Category    = "Sản phẩm";
                timkiem.Name        = product.ProductName;
                timkiem.MetaTitle   = product.MetaTitle + "-" + product.ProductId;
                timkiem.keyword     = keyword;
                timkiem.CreatedDate = product.CreateDate;
                timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: &nbsp;&nbsp;&nbsp;&nbsp; Kích ...";
                timkiem.ProductGuid = product.ProductGuid;
                ds.Add(timkiem);
            }


            // 3. Tìm kiếm trong bảng set sản phẩm
            shSectionService           _section = new shSectionService();
            IEnumerable <shProductSet> dsSet    = _section.FindList().Where(x => TypeHelper.CompareString(x.SectionName, keyword));

            foreach (var set in dsSet)
            {
                shProduct product = _product.FindByKey(set.ProductGuid);

                timkiem             = new TimKiemNangCao();
                timkiem.CategoryId  = TheLoaiTimKiemNangCao.SetSanPham.GetHashCode();
                timkiem.Category    = "Sản phẩm";
                timkiem.Name        = product.ProductName + "- Set " + set.SectionName + keyword;
                timkiem.MetaTitle   = product.MetaTitle + "-" + product.ProductId;
                timkiem.keyword     = keyword;
                timkiem.CreatedDate = set.CreateDate;
                timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: &nbsp;&nbsp;&nbsp;&nbsp; Kích ...";
                timkiem.ProductGuid = product.ProductGuid;
                ds.Add(timkiem);
            }

            // 4. Tìm kiếm trong bảng kích thước theo set
            shSizeService           _size  = new shSizeService();
            IEnumerable <shSetSize> dsSize = _size.FindList().Where(x => TypeHelper.CompareString(x.SizeName, keyword));

            foreach (var size in dsSize)
            {
                shProduct product = _product.FindByKey(size.ProductGuid);

                timkiem             = new TimKiemNangCao();
                timkiem.CategoryId  = TheLoaiTimKiemNangCao.SetSanPham.GetHashCode();
                timkiem.Category    = "Sản phẩm";
                timkiem.Name        = product.ProductName + " - Kích thước: " + size.SizeName;
                timkiem.MetaTitle   = product.MetaTitle + "-" + product.ProductId;
                timkiem.keyword     = keyword;
                timkiem.CreatedDate = size.CreateDate;
                timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: &nbsp;&nbsp;&nbsp;&nbsp; Kích ...";
                timkiem.ProductGuid = product.ProductGuid;
                ds.Add(timkiem);
            }


            // 2. Tìm kiếm trong bảng tin tức
            shNewService        _new  = new shNewService();
            IEnumerable <shNew> dsNew = _new.FindList().Where(x => TypeHelper.CompareString(x.TitleNew, keyword));

            foreach (var news in dsNew)
            {
                timkiem             = new TimKiemNangCao();
                timkiem.CategoryId  = TheLoaiTimKiemNangCao.TinTuc.GetHashCode();
                timkiem.Category    = "Tin Tức";
                timkiem.Name        = news.TitleNew;
                timkiem.MetaTitle   = news.MetaTitle + "-" + news.NewId;
                timkiem.keyword     = keyword;
                timkiem.CreatedDate = news.CreatedDate;
                timkiem.Description = news.Summary;
                ds.Add(timkiem);
            }

            return(ds);
        }
Ejemplo n.º 8
0
        public ActionResult Create(string NewGuiId, int?NewId, string TitleNew, int?SortOrder, string Descriptions, string Summary, string Contents, bool?Status, string ImageFile)
        {
            shNewService _new = new shNewService();

            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        if (!string.IsNullOrWhiteSpace(NewGuiId))
                        {
                            NewId = 0;
                        }

                        // check if contents (  ckeditor) null then rollback và yêu cầu người dùng nhập lại
                        if (string.IsNullOrEmpty(Contents))
                        {
                            shNew shnew = _new.FindByKey(NewGuiId);
                            if (shnew == null)
                            {
                                shnew = new shNew();
                            }

                            //shnew.NewId = NewId.Value;
                            //shnew.Title = Title1;
                            ViewBag.TitleNew   = TitleNew;
                            shnew.SortOrder    = SortOrder;
                            shnew.Descriptions = Descriptions;
                            shnew.Summary      = Summary;
                            shnew.Contents     = Contents;
                            shnew.Status       = Status;

                            shnew.ImageFile = ImageFile;

                            ModelState.AddModelError("", "Nội dung không được trống. Xin Vui lòng kiểm tra lại. ");
                            return(View(shnew));
                        }

                        shNew tintuc = _new.ThemMoi_HieuChinhshNew(
                            NewGuiId,
                            null,
                            TitleNew,
                            Descriptions,
                            ImageFile,
                            Summary,
                            Contents,
                            SortOrder,
                            Status,
                            DateTime.Now);
                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }


            return(RedirectToAction("Index"));
        }