Beispiel #1
0
 public void CreateUser(User user)
 {
     try
     {
         using (var context = new UniContext())
         {
             if (user == null)
             {
                 throw new ArgumentNullException();
             }
             context.Users.Add(user);
             context.SaveChanges();
         }
     }
     catch (Exception e) {
         throw e;
     }
 }
Beispiel #2
0
 public void CreateFriendship(Friendship friendship)
 {
     try
     {
         if (friendship == null)
         {
             throw new ArgumentNullException();
         }
         using (var context = new UniContext())
         {
             context.Friendships.Add(friendship);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #3
0
 public void DeleteFriendship(Friendship friendship)
 {
     try
     {
         using (var context = new UniContext())
         {
             if (friendship == null)
             {
                 throw new ArgumentNullException();
             }
             Friendship tempFriendShip = (Friendship)context.Friendships.Where(f => f.Id == friendship.Id).First();
             context.Friendships.Remove(tempFriendShip);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #4
0
 public void UpdateFriendship(Friendship friendship)
 {
     try
     {
         using (var context = new UniContext())
         {
             if (friendship == null)
             {
                 throw new ArgumentNullException();
             }
             var result = context.Friendships.SingleOrDefault(u => u.Id == friendship.Id);
             if (result != null)
             {
                 result.Accepted = true;
                 context.SaveChanges();
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }