protected void uiLinkButtonAddFriend_Click(object sender, EventArgs e) { Member member = new Member(); member.GetMemberByUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString())); MemberFriend Currentfriends = new MemberFriend(); Currentfriends.GetAllMemberFriends(member.MemberID); for (int i = 0; i < Currentfriends.RowCount; i++) { if (Currentfriends.FriendID == Convert.ToInt32(uiHiddenFieldFriendID.Value)) { // view error } else continue; } MemberFriend newfriend = new MemberFriend(); newfriend.AddNew(); newfriend.MemberID = member.MemberID; newfriend.FriendID = Convert.ToInt32(uiHiddenFieldFriendID.Value); newfriend.Save(); }
protected void uiLinkButtonAddFriend_Click(object sender, EventArgs e) { Member member = new Member(); member.GetMemberByUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString())); try { MemberFriend newfriend = new MemberFriend(); newfriend.AddNew(); newfriend.MemberID = member.MemberID; newfriend.FriendID = Convert.ToInt32(uiHiddenFieldFriendID.Value); newfriend.Save(); Member memberfriend = new Member(); memberfriend.LoadByPrimaryKey(newfriend.FriendID); // logging BLL.MemberLog log = new BLL.MemberLog(); log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.AddFriend() { FriendID = newfriend.FriendID, FriendName = memberfriend.Name }, newfriend.FriendID, null); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "ErrorAddingFriend", "$(document).ready(function (){ notify('error','خطأ. حدث خطأ . من فضلك أعد المحاولة مرة أخرى أو تأكد من وجود الصديق فى قائمة الأصدقاء.');}); ", true); } }
public void AddRemoveFriend(int mid, int fid, bool isFriend) { try { BLL.MemberFriend friend = new MemberFriend(); Member friendMember = new Member(); friendMember.LoadByPrimaryKey(fid); if (!isFriend) { friend.AddNew(); friend.MemberID = mid; friend.FriendID = fid; friend.Save(); // logging BLL.MemberLog log = new BLL.MemberLog(); log.AddNew(mid, new BLL.Log.AddFriend() { FriendID = fid, FriendName = friendMember.Name }, fid, null); var resultFriend = new { MemberID = friendMember.MemberID, Name = friendMember.Name, TypeSpecID = friendMember.MemberType.MemberTypeSpecDuration.MemberTypeSpecID, ProfilePic = (friendMember.IsColumnNull(Member.ColumnNames.ProfilePic) ? "images/defaultavatar.png" : friendMember.ProfilePic), IsOnline = friendMember.IsOnLine, StatusMsg = friendMember.s_StatusMsg, Status = Helper.EnumUtil.ParseEnum<Helper.Enums.MemberStatus>(Helper.TypeConverter.ToInt32(friendMember.s_Status)).ToString().ToLower(), IsSelected = false }; SetContentResult(resultFriend); } else { friend.DeleteFriend(mid, fid); // logging BLL.MemberLog log = new BLL.MemberLog(); log.AddNew(mid, new BLL.Log.DeleteFriend() { FriendID = fid, FriendName = friendMember.Name }, fid, null); } } catch { } }