public FriendRelationshiop Update(FriendRelationshiop friendRelationship) { using (var _ctx = new ApplicationDbContext()) { _ctx.Entry(friendRelationship).State = EntityState.Modified; _ctx.SaveChanges(); return(friendRelationship); } }
//Update friendProfile public FriendRelationshiop Update(FriendRelationshiop friendProfile) { try { return(_friendRepository.Update(friendProfile)); } catch (Exception e) { throw new Exception("Error - update the user's friend."); } }
//Add friendProfile public FriendRelationshiop Add(FriendRelationshiop friendProfile) { try { return(_friendRepository.Add(friendProfile)); } catch (Exception e) { throw new Exception("Error - add the user's friend."); } }
public FriendRelationshiop Add(FriendRelationshiop friendRelationship) { using (var _ctx = new ApplicationDbContext()) { var foundFriend = _ctx.Set <FriendRelationshiop>().Any(x => x.FriendUserProfileId == friendRelationship.FriendUserProfileId && x.UserProfileId == friendRelationship.UserProfileId); if (!foundFriend) { _ctx.Entry(friendRelationship).State = EntityState.Added; _ctx.SaveChanges(); } return(friendRelationship); } }