示例#1
0
        private static bool findById(string id)
        {
            CatalogOgranzition a = catalog.CatalogOgranzition.Where(s => s.IdOgranzition == id).FirstOrDefault();

            if (a != null)
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        public static bool CreateCatalogOgranzition(Ogranzition ogranzition)
        {
            if (findById(ogranzition.IdOgranzition))
            {
                Console.WriteLine("-----------------find");
                CatalogOgranzition catalogOgranzition = new CatalogOgranzition
                {
                    IdOgranzition   = ogranzition.IdOgranzition,
                    NameOgranzition = ogranzition.NameOgranzition
                };
                Console.WriteLine("-----------------chuan bi save");
                catalog.CatalogOgranzition.Add(catalogOgranzition);
                catalog.SaveChanges();

                Console.WriteLine("-----------------fish");

                return(true);
            }
            else
            {
                return(false);
            }
        }