public IEnumerable <shCategory> DanhSachCategory() { shCategoryService _category = new shCategoryService(); IEnumerable <shCategory> dsCategory = _category.FindList() .Where(x => x.Status == true) .OrderBy(x => x.CategoryId); return(dsCategory); }
public IEnumerable <shCategory> DanhSachCategory_ByParentId(string ParentId) { shCategoryService _category = new shCategoryService(); IEnumerable <shCategory> dsCategory = _category.FindList() .Where(x => x.Status == true && x.ParentId == ParentId) .OrderBy(x => x.CategoryId); return(dsCategory); }
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); } }
/// <summary> /// /// </summary> /// <param name="CategoryGuid"></param> /// <param name="CategoryName"></param> /// <returns></returns> public string TaoLinkUrl(string CategoryGuid, string CategoryName) { string controller = CommonHelper.GetUrlTheFirst(CategoryGuid); shCategoryService _category = new shCategoryService(); string Metatitle = _category.CategoryMetaTitle(controller); int idex = Metatitle.LastIndexOf("/"); string meta = Metatitle.Substring(0, idex); meta += "/" + StringHelper.ToUnsignString(CategoryName).ToLower(); return(Metatitle); }
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); }
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); }
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); }
public IEnumerable <shProduct> DanhSachProduct_ByUserId(int?UserId) { List <shProduct> dsProduct = new List <shProduct>(); if (UserId.HasValue) { shCategoryService _category = new shCategoryService(); IEnumerable <shCategory> dsParent = _category.FindList().Where(x => x.UserId == UserId); foreach (var parent in dsParent) { if (!string.IsNullOrEmpty(parent.ParentId) || !string.IsNullOrWhiteSpace(parent.ParentId)) // là danh mục con.. Chỉ được load danh mục con { dsProduct.AddRange(DanhSachProduct_TheoDanhMuc(parent.CategoryGuid)); } else // là danh mục cha => tìm các danh muc con { dsProduct.AddRange(DanhSachProduct_TheoDanhMuc(parent.CategoryGuid)); IEnumerable <shCategory> dsChild = _category.DanhSachCategory_ByParentId(parent.CategoryGuid); foreach (var child in dsChild) { if (child.UserId.HasValue) { if (child.UserId == UserId) { dsProduct.AddRange(DanhSachProduct_TheoDanhMuc(child.CategoryGuid)); } } else { dsProduct.AddRange(DanhSachProduct_TheoDanhMuc(child.CategoryGuid)); } } } } } else { dsProduct = DanhSachProduct().ToList(); } return(dsProduct.OrderBy(x => x.ProductId)); }
public IEnumerable <shCategory> GetCategoryByParentId(string CategoryGuid) { shCategoryService _categories = new shCategoryService(); return(_categories.FindList().Where(x => x.ParentId == CategoryGuid)); }
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); } }