示例#1
0
        public void UpdateTopHot(string CategoryGuid, bool TopHot)
        {
            shCategoryService _category = new shCategoryService();
            shCategory        category  = _category.FindByKey(CategoryGuid);

            if (category != null)
            {
                category.TopHot = TopHot;
                _category.Update(category);
            }
        }
示例#2
0
        public string CategoryName(string CategoryGuid)
        {
            if (!string.IsNullOrWhiteSpace(CategoryGuid))
            {
                shCategoryService _category = new shCategoryService();
                shCategory        category  = _category.FindByKey(CategoryGuid);

                if (category != null)
                {
                    return(category.CategoryName);
                }
                return(string.Empty);
            }
            return(string.Empty);
        }
示例#3
0
        public string CategoryName(int?CategoryId)
        {
            if (CategoryId.HasValue)
            {
                shCategoryService _category = new shCategoryService();
                shCategory        category  = _category.FindByKey(CategoryId);

                if (category != null)
                {
                    return(category.CategoryName);
                }
                return(string.Empty);
            }
            return(string.Empty);
        }
示例#4
0
        public string CategoryMetaTitle(string CategoryGuid)
        {
            string metatitle = string.Empty;

            if (!string.IsNullOrWhiteSpace(CategoryGuid))
            {
                shCategoryService _category = new shCategoryService();
                shCategory        category  = _category.FindByKey(CategoryGuid);

                if (category != null)
                {
                    return(category.MetaTitle);
                }
                return(metatitle);
            }
            return(metatitle);
        }
示例#5
0
        public shCategory ThemMoi_HieuChinhCategory(string CategoryGuid, int?CategoryId, string CategoryName, string ParentId, int?UserId, bool?Status, DateTime?CreatedDate, string MetaTitle, string Description, int?SortOrder, string FileName)
        {
            shCategoryService _category = new shCategoryService();
            shCategory        category  = new shCategory();

            if (!string.IsNullOrWhiteSpace(CategoryGuid))
            {
                category = _category.FindByKey(CategoryGuid);
            }
            else
            {
                CategoryGuid = GuidUnique.getInstance().GenerateUnique();
            }

            try
            {
                // Your code...
                // Could also be before try if you know the exception occurs in SaveChanges
                category.CategoryGuid = CategoryGuid;
                category.CategoryName = CategoryName;
                category.ParentId     = ParentId;
                category.UserId       = UserId;
                category.Status       = Status;
                category.CreatedDate  = CreatedDate;

                category.Description = Description;
                category.SortOrder   = SortOrder;

                if (string.IsNullOrWhiteSpace(ParentId) || string.IsNullOrEmpty(ParentId))
                {
                    category.MetaTitle = "/" + StringHelper.ToUnsignString(CategoryName).ToLower()
                                         + "/" + StringHelper.ToUnsignString(Description.Substring(0, 60)).ToLower();
                }
                else
                {
                    category.MetaTitle = TaoLinkUrl(CategoryGuid, CategoryName);
                }
                category.FileName = FileName;

                if (category.CategoryId > 0)
                {
                    _category.Update(category);
                }
                else
                {
                    _category.Insert(category);
                }

                return(category);
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                return(category);
            }
        }