using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Windows.Input; using MahTweets.Mango.Controllers; using MahTweets.Mango.Core.Models; using MahTweets.Mango.Models; using WindowsPhoneMVC; namespace MahTweets.Mango.ViewModels.Status { public class ComposeViewModel : ViewModelBase { private readonly ObservableCollection _accounts; private readonly string _id; public ComposeViewModel(ObservableCollection accounts, IEnumerable fromAccounts, string id, string tweetText) { _accounts = accounts; _id = id; SelectedAccounts = new ObservableCollection(accounts.Where(a => fromAccounts.Any(f => f == a.Credentials))); Text = tweetText; Transient(() => Text); SendCommand = Controller().NavigationCommand(c => c.SendStatusUpdate(AccountCredentials, Text, Id)); } public ComposeViewModel(ObservableCollection accounts) { _accounts = accounts; SelectedAccounts = new ObservableCollection(accounts); Transient(() => Text); SendCommand = Controller().NavigationCommand(c => c.SendStatusUpdate(AccountCredentials, Text, null)); } public IEnumerable AccountCredentials { get { return SelectedAccounts.Select(s => s.Credentials); } } public ICommand SendCommand { get; private set; } public string Text { get; set; } public ObservableCollection SelectedAccounts { get; private set; } public ObservableCollection Accounts { get { return _accounts; } } public string Id { get { return _id; } } } }