static void Main(string[] args) { Account account; // while ( true){ // AccountStore.InitDb(); // account = LoginScreen.DrawLogin(); // Console.ReadKey(); // } AccountStore.InitDb(); account = AccountStore.FindUser("fe", "fe"); FriendshipStore.InitDb(); // System.Console.WriteLine(FriendshipStore.friendships.First().FirstFriend); RequestStore.InitDb(); MainScreen.DrawProfile(account); // RequestStore.InitDb(); // RequestStore.remove(new Friendship{ FirstFriend = 1, SecondFriend = 6}); // RequestStore.SaveChanges(); }
public static void DrawProfile(Account account) { System.Console.WriteLine("Welcome"); // System.Console.WriteLine(account.Id); // System.Console.WriteLine(account.Login); // System.Console.WriteLine(account.Password); // System.Console.WriteLine(account.Surname); // System.Console.WriteLine(account.Name); var frds = AccountStore.accounts .Where(x => x.Id == account.Id) .Join(FriendshipStore.friendships, x => x.Id, y => y.SecondFriend, (x, y) => x).ToList(); friends = AccountStore.accounts.Join(FriendshipStore.friendships.Where(x => x.FirstFriend == account.Id), x => x.Id, y => y.SecondFriend, (x, y) => x).ToList(); // foreach (var item in friends) // { // System.Console.WriteLine(item.Id + " " + item.Name); // } requests = RequestStore.requests.Where(x => x.FirstFriend == account.Id).ToList(); // requests.Where(x=>x.SecondFriend ==) Console.CursorVisible = false; ConsoleKeyInfo btn; // foreach (var item in requests) // { // System.Console.WriteLine(item.FirstFriend + " " + item.SecondFriend); // } int cnt = 0; while (btn.Key != ConsoleKey.Escape) { draw(cnt); switch (btn.Key) { case ConsoleKey.UpArrow: if (cnt > 0) { cnt--; } break; case ConsoleKey.DownArrow: if (cnt < requests.Count - 1) { cnt++; } break; case ConsoleKey.Enter: if (requests.Any()) { FriendshipStore.friendships.Add(requests[cnt]); RequestStore.remove(requests.ElementAt(cnt)); requests.RemoveAt(cnt); } cnt = 0; break; } btn = Console.ReadKey(); } // Console.WriteLine("Start"); // foreach(var item in RequestStore.requests) // { // Console.WriteLine(item.FirstFriend + " " + item.SecondFriend); // } // Console.WriteLine("Finish"); RequestStore.SaveChanges(); FriendshipStore.SaveChanges(); }