Ejemplo n.º 1
0
        public static bool AddCategory(string categoryName, string userName, string seoTitle, string seoDescription, string seoMetaKeywords)
        {
            List <WSR_ProductCategory> categoryList = new List <WSR_ProductCategory>();
            WSR_ProductCategory        newCategory  = new WSR_ProductCategory
            {
                CategoryName    = categoryName,
                CategoryUrl     = null,
                CreatedBy       = userName,
                CreatedDate     = GetIndianTime(),
                EnabledDate     = GetIndianTime(),
                EnabledBy       = userName,
                IsActive        = true,
                IsSubcategory   = false,
                SeoTitle        = seoTitle,
                SeoDescription  = seoDescription,
                SeoMetaKeywords = seoMetaKeywords,
            };

            using (WholesaleRajaEntities db = new WholesaleRajaEntities())
            {
                categoryList = db.WSR_ProductCategory.ToList();
                bool categoryExists = categoryList.Where(x => x.IsSubcategory == false).Any(x => x.CategoryName.ToLower() == categoryName.ToLower());
                if (categoryExists)
                {
                    return(false);
                }
                else
                {
                    db.WSR_ProductCategory.Add(newCategory);
                    db.SaveChanges();
                    return(true);
                }
            }
        }
Ejemplo n.º 2
0
        public static bool AddSubcategory(int parentCategoryId, string userName, string subcategoryName, string subcategorySeoTitle, string subCategorySeoDesc, string subCategoryMetaKeywords)
        {
            List <WSR_ProductCategory> subCategoryList = new List <WSR_ProductCategory>();
            WSR_ProductCategory        newSubCategory  = new WSR_ProductCategory
            {
                CategoryName     = subcategoryName,
                CategoryUrl      = null,
                ParentCategoryId = parentCategoryId,
                CreatedBy        = userName,
                CreatedDate      = GetIndianTime(),
                EnabledDate      = GetIndianTime(),
                EnabledBy        = userName,
                IsActive         = true,
                IsSubcategory    = true,
                SeoTitle         = subcategorySeoTitle,
                SeoDescription   = subCategorySeoDesc,
                SeoMetaKeywords  = subCategoryMetaKeywords,
            };

            using (WholesaleRajaEntities db = new WholesaleRajaEntities())
            {
                subCategoryList = db.WSR_ProductCategory.Where(x => x.ParentCategoryId == parentCategoryId && x.IsSubcategory == true).ToList();
                bool subCategoryExists = subCategoryList.Where(x => x.ParentCategoryId == parentCategoryId && x.IsSubcategory == true).Any(x => x.CategoryName.ToLower() == subcategoryName.ToLower());
                if (subCategoryExists)
                {
                    return(false);
                }
                else
                {
                    db.WSR_ProductCategory.Add(newSubCategory);
                    db.SaveChanges();
                    return(true);
                }
            }
        }