Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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;
     }
 }