예제 #1
0
        public object CatAndSubCat(CatSubCat cat)
        {
            var CatCode          = cat.CatCode;
            var SubCatCode       = cat.SubCatCode;
            var ddlForPortalName = _context.tbl_PortalMaster.Where(x => x.ParentCode == (string.IsNullOrEmpty(SubCatCode) ? CatCode : SubCatCode)).Select(x => new
            {
                Id   = x.PortalCode,
                Name = x.Title
            }).ToList();

            return(Ok(ddlForPortalName));
        }
예제 #2
0
        public void SaveSubcategory(Subcategory catepara, int idcategory)
        {
            Subcategory dbEntry = mycontext.Subcategories.Find(catepara.IdSubcategory);

            //if the subcate DOESN'T exists, then add a new one.
            if (dbEntry == null)
            {
                mycontext.Subcategories.Add(catepara);

                CatSubCat mycatsubcat = new CatSubCat();
                mycatsubcat.Idcategory    = idcategory;
                mycatsubcat.IdSubcategory = catepara.IdSubcategory;
                mycontext.CatSubCats.Add(mycatsubcat);
            }
            //if the subcate exists, then modify
            if (dbEntry != null)
            {
                dbEntry.Subcatename = catepara.Subcatename;
                CatSubCat mycatsubcat = mycontext.CatSubCats.FirstOrDefault(x => x.IdSubcategory == catepara.IdSubcategory);

                mycatsubcat.Idcategory = idcategory;
            }
            mycontext.SaveChanges();
        }