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); } } }
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); } } }