示例#1
0
 public static int AnimalCategory(string name)
 {
     using (YuvamNeredeDBContext db = new YuvamNeredeDBContext())
     {
         var result = db.Category.FirstOrDefault(x => x.Name == name);
         if (result != null)
         {
             return(result.ID);
         }
         else
         {
             Category cat = new Category();
             cat.Name = name;
             db.Category.Add(cat);
             db.SaveChanges();
             return(cat.ID);
         }
     }
 }
示例#2
0
 public static int AnimalGenus(string name)
 {
     using (YuvamNeredeDBContext db = new YuvamNeredeDBContext())
     {
         var result = db.Genus.FirstOrDefault(x => x.Name == name);
         if (result != null)
         {
             return(result.ID);
         }
         else
         {
             Genus genus = new Genus();
             genus.Name = name;
             db.Genus.Add(genus);
             db.SaveChanges();
             return(genus.ID);
         }
     }
 }