public Shop_Product_Type UpdateBase(Shop_Product_Type productType, ProductTypeItem productTypeItem)
        {
            productType.Name = productTypeItem.Name;
            //productType.AgencyID = productTypeItem.AgencyID;

            return(productType);
        }
Example #2
0
        public ProductTypeItem GetItemById(int id)
        {
            var key = string.Format("ProductRepositoryGetItemById{0}", id);

            var product = new ProductTypeItem();

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

                product = new ProductTypeItem()
                {
                    ID             = result.ID,
                    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,
                    Detail         = result.Detail,
                    IsShow         = result.IsShow
                };

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

            return(product);
        }
        public ActionResult AjaxForm()
        {
            var productType = new ProductTypeItem();

            if (DoAction == ActionType.Edit)
            {
                productType = _productTypeApi.GetItemById(ArrId.FirstOrDefault());
            }
            ViewData.Model     = productType;
            ViewBag.Action     = DoAction;
            ViewBag.ActionText = ActionText;
            return(View());
        }
Example #4
0
        public ActionResult EditForm(int?id)
        {
            var obj = new ProductTypeItem();

            var listProductType = productTypeRepository.GetListForTree <object>();
            var listGroup       = productTypeGroupRepository.GetListForTree <object>();

            if (id.HasValue)
            {
                obj = productTypeRepository.GetItemById <ProductTypeItem>(id.Value);
            }

            return(Json(new
            {
                data = obj,
                listType = listProductType,
                listGroup = listGroup
            }, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        public ProductTypeItem GetByParentAsciiAndAscii(string parentAscii, string ascii)
        {
            var key = string.Format("ProductTypeRepositoryGetByParentAsciiAndAscii{0}{1}", parentAscii, ascii);

            var productType = new ProductTypeItem();

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

                if (result != null)
                {
                    productType = new ProductTypeItem()
                    {
                        ID              = result.ID,
                        Name            = result.Name,
                        NameAscii       = result.NameAscii,
                        ParentName      = result.tblTypeProduct2.Name,
                        ParentNameAscii = result.tblTypeProduct2.NameAscii,
                        Detail          = result.Detail,
                        IsShow          = result.IsShow,
                        ListPicture     = result.tblPicture1.Select(p => new PictureItem()
                        {
                            ID       = p.ID,
                            Link     = p.Link,
                            FileName = p.FileName
                        }).ToList()
                    };
                }

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

            return(productType);
        }
Example #6
0
        public ProductTypeItem GetByAsciiAndParent(string ascii, int parentId)
        {
            var key = string.Format("ProductTypeRepositoryGetByAsciiAndParent{0}{1}", ascii, parentId);

            var product = new ProductTypeItem();

            if (!this.TryGetCache <ProductTypeItem>(out product, key))
            {
                var query = from p in web365db.tblTypeProduct
                            where p.NameAscii == ascii && p.Parent == parentId && p.LanguageId == LanguageId
                            orderby p.ID descending
                            select new ProductTypeItem()
                {
                    ID              = p.ID,
                    Name            = p.Name,
                    NameAscii       = p.NameAscii,
                    ParentName      = p.tblTypeProduct2.Name,
                    ParentNameAscii = p.tblTypeProduct2.NameAscii,
                    SEOTitle        = p.SEOTitle,
                    SEODescription  = p.SEODescription,
                    SEOKeyword      = p.SEOKeyword,
                    DateCreated     = p.DateCreated,
                    DateUpdated     = p.DateUpdated,
                    Number          = p.Number,
                    PictureID       = p.PictureID,
                    Detail          = p.Detail,
                    IsShow          = p.IsShow
                };

                product = query.FirstOrDefault();

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

            return(product);
        }
        public ActionResult Actions()
        {
            var msg         = new JsonMessage();
            var productType = new ProductTypeItem();
            List <ProductTypeItem> ltsproductType;
            var json  = "";
            var lstId = Request["itemId"];

            switch (DoAction)
            {
            case ActionType.Add:
                try
                {
                    UpdateModel(productType);

                    json = new JavaScriptSerializer().Serialize(productType);
                    _productTypeApi.Add(json);
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = productType.ID.ToString(),
                        Message = string.Format("Đã thêm mới hành động: <b>{0}</b>", Server.HtmlEncode(productType.Name))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;

            case ActionType.Edit:
                try
                {
                    UpdateModel(productType);

                    json = new JavaScriptSerializer().Serialize(productType);
                    _productTypeApi.Update(json, ArrId.FirstOrDefault());

                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = productType.ID.ToString(),
                        Message = string.Format("Đã cập nhật : <b>{0}</b>", Server.HtmlEncode(productType.Name))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;

            case ActionType.Delete:
                var lst1  = string.Join(",", ArrId);
                var check = _productTypeApi.Delete(lst1);
                if (check == 1)
                {
                    msg.Erros   = false;
                    msg.Message = "Đã xóa Type";
                }
                else
                {
                    msg.Erros   = true;
                    msg.Message = "Lỗi khi xóa Type";
                }
                break;
            }

            if (string.IsNullOrEmpty(msg.Message))
            {
                msg.Message = "Không có hành động nào được thực hiện.";
                msg.Erros   = true;
            }

            return(Json(msg, JsonRequestBehavior.AllowGet));
        }