Exemple #1
0
        public bool IsCategoryNameExist(CategoryVM cat)
        {
            ModernMarketResearchEntities db = new ModernMarketResearchEntities();

            bool flag = false;

            //same name of child and parent cat,to check that find out the catid of same catname
            var Catid = db.CategoryMasters.Where(x => x.CategoryName == cat.CategoryName).Select(x => x.CategoryId).FirstOrDefault();

            //Same name of Category of same parentcategory, to check that find out the parent of same catname
            var Parentcatid = db.CategoryMasters.Where(x => x.CategoryName == cat.CategoryName).Select(x => x.ParentCategoryId).FirstOrDefault();

            if (Catid != 0 || Parentcatid != null)
            {
                //check the condition if true duplicate catname error ...
                if (Catid == cat.ParentCategoryId || Parentcatid == cat.ParentCategoryId)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
            }
            else
            {
                flag = false;
            }

            return(flag);
        }
Exemple #2
0
 public CategoryRepository()
 {
     db = new ModernMarketResearchEntities();
 }