public async Task CreateConversation(string friendId, string friendUsername) { IsBusy = true; try { Conversation = new Conversation { MyId = settings.User.Id, UserId = friendId, Username = friendUsername }; var currentConversation = await service.CreateConversation(Conversation); Conversation = currentConversation; if(Conversations.Length < 1) { Conversations = new Conversation[]{Conversation}; } } finally { IsBusy = false; } }
public async Task LoadData() { var users = client.GetTable<User>(); var friends = client.GetTable<Friend>(); var conversations = client.GetTable<Conversation>(); var messages = client.GetTable<Message>(); var userList = await client.GetTable<User>().Where (u => u.Username == "Nick").ToListAsync(); var me = userList [0]; userList = await client.GetTable<User>().Where (u => u.Username == "Chuck").ToListAsync (); var friend = userList [0]; var conversation = new Conversation { MyId = me.Id, UserId = friend.Id, Username = friend.Username, LastMessage = "HEY!" }; await conversations.InsertAsync(conversation); await messages.InsertAsync(new Message { ConversationId = conversation.Id, UserId = friend.Id, Username = friend.Username, Text = "What's up?", Date = DateTime.Now.AddSeconds(-60), }); await messages.InsertAsync(new Message { ConversationId = conversation.Id, UserId = me.Id, Username = me.Username, Text = "Not much", Date = DateTime.Now.AddSeconds(-30), }); await messages.InsertAsync(new Message { ConversationId = conversation.Id, UserId = friend.Id, Username = friend.Username, Text = "HEY!", Date = DateTime.Now, }); }
public async Task<Conversation> CreateConversation(Conversation conversation) { await Sleep (); return conversation; }
public async Task<Conversation> CreateConversation(Conversation conversation) { await client.GetTable<Conversation>().InsertAsync(conversation); var conversations = await client.GetTable<Conversation> ().Where (c => c.MyId == conversation.MyId && c.UserId == conversation.UserId).ToListAsync(); return conversations[0]; }