Exemplo n.º 1
0
 public static void AddOrUpdateLink(Person follower, Person leader)
 {
     using (var db = new CloutContext())
     {
         db.Following.AddOrUpdate(new Following { PersonId = follower.Id, FollowingId = leader.Id });
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
        public static Person GetOrAddPerson(string name)
        {
            using (var db = new CloutContext())
            {
                var person = db.Person.SingleOrDefault(p => p.Name == name);
                if (person == null)
                {
                    db.Person.Add(new Person { Name = name });
                    db.SaveChanges();
                }

                return person ?? db.Person.SingleOrDefault(p => p.Name == name);
            }
        }