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