Ejemplo n.º 1
0
        public void DeleteSub(int Sub_Category_ID)
        {
            DBModel context = new DBModel();
            DbRepository <Sub_Categroy> repoSubCategory = new DbRepository <Sub_Categroy>(context);

            Sub_Categroy sub = repoSubCategory.GetAll().FirstOrDefault((x) => x.Sub_Category_ID == Sub_Category_ID);

            repoSubCategory.Delete(sub);
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public bool AddSubCategory(SubCategoryViewModel input)
        {
            DBModel context = new DBModel();
            //DbRepository<CategoryGroup> Crepo = new DbRepository<CategoryGroup>(context);
            DbRepository <Sub_Categroy> Srepo = new DbRepository <Sub_Categroy>(context);

            if (Srepo.GetAll().FirstOrDefault((x) => x.Category_Name == input.Category_Name) == null)
            {
                Sub_Categroy entity = new Sub_Categroy()
                {
                    Sub_Category_ID = input.Sub_Category_ID,
                    Category_Name   = input.Category_Name,
                    Category_ID     = input.Category_ID
                };
                Srepo.Create(entity);
                context.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }