コード例 #1
0
        public ProductItem GetItemById(int id)
        {
            var key = string.Format("ProductRepositoryGetItemById{0}", id);

            var product = new ProductItem();

            if (!this.TryGetCache<ProductItem>(out product, key))
            {
                var result = GetById(id);

                product = new ProductItem()
                {
                    ID = result.ID,
                    TypeID = result.TypeID,
                    Name = result.Name,
                    NameAscii = result.NameAscii,
                    SEOTitle = result.SEOTitle,
                    SEODescription = result.SEODescription,
                    SEOKeyword = result.SEOKeyword,
                    DateCreated = result.DateCreated,
                    DateUpdated = result.DateUpdated,
                    Number = result.Number,
                    PictureID = result.PictureID,
                    Summary = result.Summary,
                    Detail = result.Detail,
                    IsShow = result.IsShow
                };

                this.SetCache(key, product, 10);
            }

            return product;
        }
コード例 #2
0
        public ProductItem GetItemByAscii(string ascii)
        {
            var key = string.Format("ProductRepositoryGetItemByAscii{0}", ascii);

            var product = new ProductItem();

            if (!this.TryGetCache<ProductItem>(out product, key))
            {
                var result = (from p in web365db.tblProduct
                            where p.NameAscii == ascii && p.IsShow == true && p.IsDeleted == false
                            orderby p.ID descending
                            select p).FirstOrDefault();

                product = new ProductItem()
                {
                    ID = result.ID,
                    TypeID = result.TypeID,
                    Name = result.Name,
                    NameAscii = result.NameAscii,
                    SEOTitle = result.SEOTitle,
                    SEODescription = result.SEODescription,
                    SEOKeyword = result.SEOKeyword,
                    DateCreated = result.DateCreated,
                    DateUpdated = result.DateUpdated,
                    Number = result.Number,
                    PictureID = result.PictureID,
                    HighLights = result.HighLights,
                    Summary = result.Summary,
                    Detail = result.Detail,
                    IsShow = result.IsShow,
                    Picture = new PictureItem() {
                        FileName = result.tblPicture != null ? result.tblPicture.FileName : string.Empty
                    },
                    ListPicture = result.tblPicture1.Select(p => new PictureItem() {
                        FileName = p.FileName
                    }).ToList(),
                    ListFile = result.tblFile.Select(p => new FileItem()
                    {
                        Name = p.Name,
                        FileName = p.FileName
                    }).ToList()
                };

                this.SetCache(key, product, 10);
            }

            return product;
        }
コード例 #3
0
        public ActionResult EditFormFilter(int id)
        {
            var obj = new ProductItem();

            obj = productRepository.GetEditFormFilter(id);

            return Json(new
            {
                data = obj
            }, JsonRequestBehavior.AllowGet);
        }
コード例 #4
0
        public ActionResult EditForm(int? id)
        {
            var obj = new ProductItem();

            var listType = productTypeRepository.GetListForTree<object>();

            var listDistributor = distributorRepository.GetListForTree<object>();

            var listManufacturer = manufacturerRepository.GetListForTree<object>();

            var listStatus = productStatusRepository.GetListForTree<object>();

            var listLabel = productLabelRepository.GetListForTree<object>();

            if (id.HasValue)
                obj = productRepository.GetItemById<ProductItem>(id.Value);

            return Json(new
            {
                data = obj,
                listType = listType,
                listDistributor = listDistributor,
                listManufacturer = listManufacturer,
                listStatus = listStatus,
                listLabel = listLabel
            }, JsonRequestBehavior.AllowGet);
        }