private void LoadSentGifts() { MemberGift gifts = new MemberGift(); gifts.GetMemberSentGifts(Member.CurrentMemberID); uiGridViewOutbox.DataSource = gifts.DefaultView; uiGridViewOutbox.DataBind(); uiPanelOutbox.Visible = true; uiPanelInbox.Visible = false; }
public bool SendGift(string memberName, int roomID, string roomName, Helper.Item[] friends, int giftid, string uniqueID) { MembershipUser user = Membership.GetUser(); Member member = new Member(); member.GetMemberByUserId(new Guid(user.ProviderUserKey.ToString())); Gift srcgift = new Gift(); srcgift.LoadByPrimaryKey(giftid); if (!(member.Credit_Point >= srcgift.Price_Point * friends.Length)) return false; foreach (Helper.Item item in friends) { MemberGift gift = new MemberGift(); gift.AddNew(); gift.MemberID = item.ID; gift.SenderID = member.MemberID; gift.SendDate = DateTime.Now; gift.GiftID = giftid; gift.Save(); member.Credit_Point = member.Credit_Point - srcgift.Price_Point; member.Save(); // check if in room or send to friend if (roomID != 0) { IHubContext _Ncontext = GlobalHost.ConnectionManager.GetHubContext<ChatRoomHub>(); if (uniqueID.Contains("Room")) _Ncontext.Clients.Group(roomID.ToString()).GiftSentInRoom(roomID, memberName, item.Name, srcgift.Name, item.ID, srcgift.PicPath, srcgift.AudioPath, uniqueID); else if (uniqueID.Contains("Private")) { var toUser = ChatRoomHub.ConnectedUsers.FirstOrDefault(x => x.MemberID == roomID); var fromUser = ChatRoomHub.ConnectedUsers.FirstOrDefault(x => x.MemberID == member.MemberID); _Ncontext.Clients.Client(toUser.ConnectionId).GiftSentInRoom(roomID, memberName, item.Name, srcgift.Name, item.ID, srcgift.PicPath, srcgift.AudioPath, uniqueID); _Ncontext.Clients.Client(fromUser.ConnectionId).GiftSentInRoom(roomID, memberName, item.Name, srcgift.Name, item.ID, srcgift.PicPath, srcgift.AudioPath, uniqueID); } } } return true; }