private void ShowFriendSelectedMonth() { if (selectedMonth == "Все" || selectedMonth == null) { return; } int month; try { month = Convert.ToInt32(selectedMonth); } catch { return; } var tempList = CopyCollection(FriendsList); FriendsList.Clear(); foreach (var friend in tempList) { if (friend.Month == month) { FriendsList.Add(friend); } } }
public async Task CreateFriendsListsAsync() { Storage pStoStorage = new Storage("TableStorageRootURL", "AzureWebJobsStorage", "Test"); foreach (CreateUserArgs curUser in cLisUsers) { FriendsList pFLtFriends = null; User pUsrUser = await pStoStorage.GetUserAsync(GetTestUserPrincipal(curUser.Email)); foreach (CreateUserArgs curFriend in curUser.Friends) { System.Diagnostics.Debug.WriteLine(String.Format("Adding friend '{0}' to user '{1}'.", curFriend.UserName, curUser.UserName)); User pUsrFriend = await pStoStorage.GetUserAsync(GetTestUserPrincipal(curFriend.Email)); pFLtFriends = pUsrUser.GetFriends(pStoStorage); Assert.IsTrue(pFLtFriends.AddFriend(pStoStorage, pUsrFriend)); } pFLtFriends = pUsrUser.GetFriends(pStoStorage); foreach (Friend curFriend in pFLtFriends.Friends) { Assert.IsTrue(curUser.HasFriend(curFriend.UserName)); } } }
public async Task RemoveFriendsFromFriendsListsOneByOneAsync() { Storage pStoStorage = new Storage("TableStorageRootURL", "AzureWebJobsStorage", "Test"); foreach (CreateUserArgs curUser in cLisUsers) { FriendsList pFLtFriends = null; User pUsrUser = await pStoStorage.GetUserAsync(GetTestUserPrincipal(curUser.Email)); foreach (CreateUserArgs curFriend in curUser.Friends) { System.Diagnostics.Debug.WriteLine(String.Format("Removing friend '{0}' from user '{1}'.", curFriend.UserName, curUser.UserName)); User pUsrFriend = await pStoStorage.GetUserAsync(GetTestUserPrincipal(curFriend.Email)); pFLtFriends = pUsrUser.GetFriends(pStoStorage); Int32 pIntPreRemovalCount = pFLtFriends.Friends.Count; Friend pFrdFriend = pFLtFriends.GetFriendByUserName(curFriend.UserName); Assert.IsTrue(pFLtFriends.RemoveFriend(pStoStorage, pFrdFriend)); FriendsList pFLtFriendsPostRemoval = pUsrUser.GetFriends(pStoStorage); pFrdFriend = pFLtFriendsPostRemoval.GetFriendByUserName(curFriend.UserName); Assert.IsNull(pFrdFriend); } } }
public void ResetCache() { GiveAwayCount = 0; FriendsList.Clear(); ApplyList.Clear(); TodayRobList.Clear(); }
public async Task AddFriendToFriendsListAsync(User user) { DependencyService.Get <IFirebaseDatabase>().AddFriend(user); await App.Current.MainPage.DisplayAlert("Successful Message", "New friend added", "Ok"); FriendsList.Add(user); }
public void UpdateStatus(string emailId, int userId) { string connectionString = ConfigurationManager.ConnectionStrings["ExpenseEntities"].ConnectionString; ExpenseEntities _dbcontext1 = ExpenseEntities.CreateEntitiesForSpecificDatabaseName(connectionString); var currentUser = (from usr in _dbcontext1.UsersInfoes where usr.EmailId == emailId select new { usr.Id, usr.EmailId }); if (currentUser != null) { var friendId = currentUser.FirstOrDefault().Id; if (friendId != 0) { var frndList = new FriendsList() { FriendId = friendId, UserId = userId, Active = 1, Created_On = DateTime.Now, Updated_on = DateTime.Now }; _dbcontext1.FriendsLists.Add(frndList); _dbcontext1.SaveChanges(); } SendInviteEmail(emailId, currentUser.FirstOrDefault().EmailId); } }
// Draw public override void Draw() { friendsList = InGameLobby.instance.displayedAccount.friends; if (friendsList == null) { return; } // Body using (new GUIScrollView(ref scrollPosition)) { using (new GUIVertical()) { // Friends foreach (var group in friendsList.groups) { DrawFriendsGroup(group); } // Footer DrawFooter(); // Followers DrawFollowers(); } } }
void ReceiveFriendsList(string accountId, string newList) { friendsList = Jboy.Json.ReadObject <FriendsList>(newList); PlayerAccount.Get(accountId).friends = friendsList; LogManager.General.Log("FriendsGUI: Received friends list: " + friendsList); }
private void ShowFriendOperatorWith() { if (selectedOperator == "Все" || selectedOperator == null) { return; } PhoneOperator phoneOperator = null; foreach (var item in PhoneOperators) { if (item.Name == selectedOperator) { phoneOperator = item; } } if (phoneOperator == null) { return; } var tempList = CopyCollection(FriendsList); FriendsList.Clear(); foreach (var friend in tempList) { if (phoneOperator.IsCodeContains(friend.NumberCode)) { FriendsList.Add(friend); } } }
private void RefreshDataSource() { FriendsList.DataSource = DAL.DataAccessLayer.GetFriends((Guid)Membership.GetUser().ProviderUserKey, "ListFriends"); FriendsList.DataBind(); NonFriendsList.DataSource = DAL.DataAccessLayer.GetFriends((Guid)Membership.GetUser().ProviderUserKey, "ListNonFriends"); NonFriendsList.DataBind(); }
// Constructor public LobbyPlayer(Account nAccount) { account = nAccount; peer = AccountManager.Master.GetLoggedInPeer(account); statusObservers = new HashSet <LobbyPlayer>(); statusObservers.Add(this); stats = null; ffaStats = null; custom = null; friends = null; _location = null; _followers = null; _party = new LobbyParty(); _gameInstance = null; artifactsEditingFlag = false; channels = new List <LobbyChatChannel>(); chatMember = new ChatMember(account.id.value); accountsWhereInfoIsRequired = new HashSet <string>(); LobbyPlayer.list.Add(this); LobbyPlayer.accountIdToLobbyPlayer[account.id.value] = this; LobbyPlayer.peerToLobbyPlayer[peer] = this; }
public void GetAllFriendListsAndFriendsTests_Should_CallMethod_GetAllFriendLists() { var userServiceMocked = new Mock <IUserService>(); var groupsServiceMocked = new Mock <IGroupService>(); var friendListServiceMocked = new Mock <IFriendListService>(); var friendList = new FriendsList() { Name = "testGroup", Friends = new List <Friend>() { new Friend() { Name = "testAuthor", Gender = false } } }; friendListServiceMocked.Setup(m => m.GetAll()) .Returns(new List <FriendsList>() { friendList }); var controller = new AdministrationController(groupsServiceMocked.Object, friendListServiceMocked.Object, userServiceMocked.Object); controller.GetAllFriendListsAndFriends(); friendListServiceMocked.Verify(m => m.GetAll(), Times.Once); }
public static bool SignIn(string request) { string[] postReqKV = request.Split(GlobalVar.delimiterChars, System.StringSplitOptions.RemoveEmptyEntries); string usrTemp = postReqKV[1]; string passTemp = postReqKV[3]; Encrypt.encryptText = usrTemp; usrTemp = Encrypt.GlobalVar; string pT = NpgSQLLogin(usrTemp); if (pT != "error") { Encrypt.encryptText = passTemp; if (Encrypt.GlobalVar == pT) { FriendsList.SetOnline(postReqKV[1], "true"); return(true); } else { return(false); } } return(false); }
// Start void Start() { friendsList = null; // Listen to lobby events Lobby.AddListener(this); }
public void BnetFriendReceived(BnetFriend friend) { DispatcherHelper.CheckBeginInvokeOnUI(() => { FriendsList.Add(friend); }); }
public async Task <ActionResult <FriendsList> > PostFriendsList(FriendsList friendsList) { _context.friendsLists.Add(friendsList); await _context.SaveChangesAsync(); return(CreatedAtAction("GetFriendsList", new { id = friendsList.FriendsId }, friendsList)); }
public void Constructor_ShouldInitializePropertiesCorrectly() { var friend = new FriendsList("testFriendList"); Assert.AreEqual(friend.Name, "testFriendList"); Assert.IsNotNull(friend.Friends); }
// you have ben removed from friends private async void RemovedFromeFriends(string login, DateTime time) { await System.Threading.Tasks.Task.Run(() => System.Threading.Thread.Sleep(Properties.Settings.Default.ActionDelayMsec)); FriendsList.Remove(FriendsList.FirstOrDefault(x => x.Name.Equals(login))); }
public IActionResult CreateSave(FriendsList friendsList, string?id) { var identidade = _userManager.GetUserId(User); if (id == null) { return(NotFound()); } if (!_baseContext.FriendsExist(id)) { if (identidade.Contains(id)) { return(RedirectToAction(nameof(Index))); } friendsList.ApplicationUserId = id; var post = _baseApi.Consumer.PostAsJsonAsync <FriendsList>("api/FriendsListsApi", friendsList); post.Wait(); var result = post.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } ViewBag.Text = "Friend has already been added to the list!!"; return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> PutFriendsList(int id, FriendsList friendsList) { if (id != friendsList.FriendsId) { return(BadRequest()); } _context.Entry(friendsList).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FriendsListExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
async Task CompleteItem(FriendsList item) { //await manager.SaveTaskAsync(item); App.FriendsManager.DeleteTaskAsync(item); var list = await App.FriendsManager.GetTasksAsync(); listView.ItemsSource = list; }
public static void StreamLoadFriends(out FriendsList friends) { _reader = new StreamReader(FriendsPath); var json = _reader.ReadToEnd(); _reader.Dispose(); friends = JsonConvert.DeserializeObject <FriendsList>(json); }
public void Name_ShouldWorkCorrectly() { var friend = new FriendsList("test"); friend.Name = "test1"; Assert.AreEqual(friend.Name, "test1"); }
async Task CompleteAdd(FriendsList item) { await App.FriendsManager.SaveTaskAsync(item, true); var list = await App.FriendsManager.GetTasksAsync(); listView.ItemsSource = list; }
private void ApplyFilters() { FriendsList.Clear(); FriendsList = DbConnection.SelectAll(); ShowFriendsWithNumber(); ShowFriendSelectedMonth(); ShowFriendOperatorWith(); }
public static void StreamSaveFriends(FriendsList list) { _writer = new StreamWriter(FriendsPath); var json = JsonConvert.SerializeObject(list); _writer.Write(json); _writer.Dispose(); }
public new void EncodeForTransfer(Packet pw) { pw.WriteByte(ChannelID); pw.WriteByte(LastChannel); FriendsList.EncodeForTransfer(pw); base.EncodeForTransfer(pw); }
public void FriendsListXmlTest() { FriendsList friends = new FriendsList(); XmlDocument xml = Serializer.SerializeToXml(friends); Assert.IsNotNull(xml.SelectSingleNode("FRIENDSLIST")); }
/// <summary> /// 删除好友 /// </summary> /// <returns></returns> public void RemoveFriend(int uid) { FriendData fd = FriendsList.Find(t => (t.UserId == uid)); if (fd != null) { FriendsList.Remove(fd); } }
// Set friends public static Coroutine SetFriends(string accountId, FriendsList friends, GameDB.ActionOnResult <FriendsList> func = null) { return(GameDB.instance.StartCoroutine(GameDB.Set <FriendsList>( "AccountToFriends", accountId, friends, func ))); }
public static Tuple <string[], string[], string[], string[]> LoadInformation(string username) { try { using (NpgsqlConnection conn = new NpgsqlConnection(Network.NpgSQLConnection)) { string text = ""; conn.Open(); NpgsqlCommand myCommand = new NpgsqlCommand("SELECT * FROM embyrfriends.friends WHERE accountname = @accountname", conn); myCommand.Parameters.Add(new NpgsqlParameter(":accountname", username)); NpgsqlDataReader friendsReader = myCommand.ExecuteReader(); friendsReader.Read(); string friendsFromDB = friendsReader[2].ToString(); text = friendsFromDB; string[] friends = text.Split(GlobalVar.delimiterChars, System.StringSplitOptions.RemoveEmptyEntries); string requestsIn = friendsReader[3].ToString(); text = requestsIn; string[] reqIn = text.Split(GlobalVar.delimiterChars, System.StringSplitOptions.RemoveEmptyEntries); string requestsOut = friendsReader[4].ToString(); text = requestsOut; string[] reqOut = text.Split(GlobalVar.delimiterChars, System.StringSplitOptions.RemoveEmptyEntries); conn.Close(); string[] friendsStatus = new string[friends.Length]; int i = 0; foreach (string friend in friends) { friendsStatus[i] = FriendsList.GetStatus(friend); i++; } var tuple = new Tuple <string[], string[], string[], string[]>(friends, reqIn, reqOut, friendsStatus); return(tuple); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(null); } }
public void Process(Context context) { if (Nickname.Length > MAX_LENGTH) { Nickname = Nickname.Substring(0, MAX_LENGTH); } context.Server.Database.UpdateNickname(context.User, Nickname); var updatedFriendsList = new FriendsList(context.User); context.Server.Database.QueryFriends(context.User).ForEach(friend => { var friendSession = context.Server.GetSession(friend); if(friendSession != null) { friendSession.SendAndProcessMessage(updatedFriendsList); } }); }
public void Process(Context context) { var clientPrefs = new Unknown10(); context.SendAndProcessMessage(clientPrefs); var groups = new Groups(); context.SendAndProcessMessage(groups); var groupsFriends = new GroupsFriends(); context.SendAndProcessMessage(groupsFriends); var serverList = new ServerList(); context.SendAndProcessMessage(serverList); var chatRooms = new ChatRooms(); context.SendAndProcessMessage(chatRooms); var friendsList = new FriendsList(context.User); context.SendAndProcessMessage(friendsList); var friendsStatus = new FriendsSessionAssign(context.User); context.SendAndProcessMessage(friendsStatus); // Tell friends this user came online //if (context.User.Username == "test") Debugger.Break(); var friends = context.Server.Database.QueryFriends(context.User); friends.ForEach(friend => { var otherSession = context.Server.GetSession(friend); if (otherSession != null) { otherSession.SendAndProcessMessage(new FriendsSessionAssign(friend)); } }); var pendingFriendRequests = context.Server.Database.QueryPendingFriendRequests(context.User); pendingFriendRequests.ForEach(request => { var requester = context.Server.Database.QueryUser(request.UserId); context.SendAndProcessMessage(new FriendInvite(requester.Username, requester.Nickname, request.Message)); }); }
/// <summary> /// @Author: Jivanjot Brar /// POST: if the user chooses Accept friend request, this function takes the id of the user /// who chooses "accept" and who sent the request and adds the row to the friendslist table /// and also access the row entered by the user who sent the request and changes the status /// from "pending" to "accepted" /// </summary> /// <param name="friendID">Takes in the the id of the user who sent the request.</param> /// <param name="userID">Id of the user to whom the request was sent.</param> /// <returns></returns> public ActionResult AcceptRequest(int friendID, int userID) { try { HeartbeatMonitor loginTimer = new HeartbeatMonitor(SessionHandler.UID, HttpContext); var friend = (from fr in db.FriendsLists where fr.id == userID && fr.friend_id == friendID select fr).FirstOrDefault(); if (friend != null) { friend.status = "accepted"; } else { FriendsList fl = new FriendsList(); fl.id = userID; fl.friend_id = friendID; fl.num_requests_sent = 0; fl.status = "accepted"; db.FriendsLists.Add(fl); } friend = (from fr in db.FriendsLists where fr.id == friendID && fr.friend_id == userID select fr).FirstOrDefault(); if (friend != null) { friend.status = "accepted"; } var user = (from usr in db.Users where usr.id == userID select usr).FirstOrDefault(); string userImage = user.image_url; UserMessage um = new UserMessage(); um.datetime_sent = DateTime.Now; um.sender_id = userID; um.recipient_id = friendID; um.subject = "Friend Request Accepted"; um.message = "<table><tr>" + "<td border=\"0px\"> <img src=\"" + "../" + userImage + "\" height=\"50px\" width=\"45px\" /> </td>" + "<td>" + user.firstname + " " + user.lastname + " has accepted your friend request. </td>" + "</tr></table>"; um.message_read = false; // add the message to the user messages table db.UserMessages.Add(um); // save the changes made to the database db.SaveChanges(); // Redirect to specified view return RedirectToAction("Index", "FriendList"); } catch (Exception ex) { return View("~/Views/Shared/Error.cshtml", ex); } }
public ActionResult Find(FormCollection fm) { bool sendRequest = true; if (SessionHandler.Logon) { try { HeartbeatMonitor loginTimer = new HeartbeatMonitor(SessionHandler.UID, HttpContext); //display a list of users not including the active user int temp = Convert.ToInt32(fm.GetKey(0)); FriendsList friend = (from f in db.FriendsLists where f.id == SessionHandler.UID && f.friend_id == temp select f).FirstOrDefault(); if (friend != null) { if (friend.num_requests_sent < 10) { int i = friend.num_requests_sent; friend.num_requests_sent = ++i; friend.status = "pending"; } else { sendRequest = false; } } else { // Add a request to the friends list table FriendsList fl = new FriendsList(); fl.id = SessionHandler.UID; fl.friend_id = temp; fl.num_requests_sent = 1; fl.status = "pending"; db.FriendsLists.Add(fl); } if (sendRequest) { // get current users information User c_user = (from userT in db.Users where userT.id == SessionHandler.UID select userT).FirstOrDefault(); // current users image string userImage = c_user.image_url; //send friend request message to the select user in find friends form. UserMessage um = new UserMessage(); // current date and time, when message was sent um.datetime_sent = DateTime.Now; //this is the ID of the current logged in user um.sender_id = SessionHandler.UID; //This is the ID of the user, who is being sent the friend request. um.recipient_id = temp; um.subject = "Friend Request"; um.message = "<table><tr>" + "<tdborder=\"0px\"> <img src=\"" + "../" + userImage + "\" height=\"50px\" width=\"45px\"/> </td>" + "<td>" + c_user.firstname + " " + c_user.lastname + " has sent you a friend request. </td>" + "<td><a href=\"../../../FriendList/AcceptRequest/?friendID=" + SessionHandler.UID + "&userID=" + temp + "\">Accept</a></td>" + "<td><a href=\"../../../FriendList/DeclineRequest/?friendID=" + SessionHandler.UID + "&userID=" + temp + "\">Decline</a></td>" + "</tr></table>"; um.message_read = false; // add the message to the user messages table db.UserMessages.Add(um); // save the changes made to the database. db.SaveChanges(); } // Redirect to specified view return RedirectToAction("Find", "FriendList"); } catch (Exception ex) { return View("~/Views/Shared/Error.cshtml", ex); } } else { //must go to the login action return RedirectToAction("Index", "Login"); } }
void Start() { friendsList = this; LoadFriendsList(); }
/// <summary> /// Returns a test FriendsList /// </summary> /// <returns></returns> public static FriendsList CreateTestFriendsList() { var friends = new FriendsList() { Friends = new List<UserElement> { new UserElement() { user = UserTest.CreateTestUser() } } }; return friends; }
public void GetCacheKeyTest() { var friends = new FriendsList(); string expected = string.Format("{0}|0|0|0|0|True|0|", typeof(FriendsList).AssemblyQualifiedName); string actual = friends.GetCacheKey(0, 0, 0, 0, true, 0); Assert.AreEqual(expected, actual); }
public void IsUpToDate_FriendsListOutOfDate_ReturnsCorrect() { // PREPARE THE TEST // setup the default mocks MockRepository mocks = new MockRepository(); var target = new FriendsList() { Friends = new List<UserElement> { new UserElement() { user = UserTest.CreateTestUser() } } }; var reader = mocks.DynamicMock<IDnaDataReader>(); reader.Stub(x => x.HasRows).Return(true); reader.Stub(x => x.Read()).Return(false); var creator = mocks.DynamicMock<IDnaDataReaderCreator>(); mocks.ReplayAll(); Assert.AreEqual(false, target.IsUpToDate(creator)); }
public FriendsManager() { FriendsList = new FriendsList(Factory.CurrentTheme); Friends = new List<Friend>(); Factory.Nexoid.ConnectionChange += new EventHandler(Nexoid_ConnectionChange); }