Example #1
0
        public override void OnNavigatingTo(NavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);
            if (parameters["user"] != null)
            {
                var user = (UserDto)parameters["user"];
                if (user != null)
                {
                    if (!IsUserInGroup(user))
                    {
                        var newCollection = new ObservableCollection <UserDto>(UsersInGroup);
                        newCollection.Insert(UsersInGroup.Count - 1, user);

                        //Terrible
                        UsersInGroup.Clear();
                        foreach (var u in newCollection)
                        {
                            UsersInGroup.Add(u);
                        }
                    }
                }
            }
            else
            {
                if (parameters["group"] != null)
                {
                    this.Group = (GroupDto)parameters["group"];
                    RaisePropertyChanged(nameof(Group));
                    GroupName        = Group.Name;
                    TrackCost        = Group.TrackCost;
                    SelectedIconName = Group.GroupIconName;
                    RaisePropertyChanged(nameof(GroupName));
                    //UsersInGroup = new ObservableCollection<ShoutUserDto>(Group.Users);
                    UsersInGroup.Clear();
                    UsersInGroup = new ObservableCollection <UserDto>(Group.Users);
                    RaisePropertyChanged(nameof(UsersInGroup));
                }
                else
                {
                    UsersInGroup.Add(Settings.Current.User);

                    UserDto u = new UserDto();
                    u.ID        = DummyGuid;
                    u.AvatarUrl = "ic_plus_white_18dp.png";
                    UsersInGroup.Add(u);
                }

                if (parameters["shout"] != null)
                {
                    ShoutFromEdit = (RecordDto)parameters["shout"];
                }

                if (parameters["edit"] != null)
                {
                    IsEdit = true;
                    Title  = "Edit Group";
                    RaisePropertyChanged(nameof(IsEdit));
                }
            }
        }
Example #2
0
        public async void OnUserClickedCommand(int?index)
        {
            if (!IsEdit && index.HasValue)
            {
                if (index == 0)
                {
                    return;
                }
                else if (index == UsersInGroup.Count - 1)
                {
                    //Push to page
                    NavigationParameters nav = new NavigationParameters();
                    nav.Add("friends", Friends);
                    await _navigationService.NavigateAsync("AddUserToGroupPage", nav);
                }
                else
                {
                    var newCollection = new ObservableCollection <UserDto>(UsersInGroup);
                    newCollection.RemoveAt(index.Value);

                    //Terrible
                    UsersInGroup.Clear();
                    foreach (var u in newCollection)
                    {
                        UsersInGroup.Add(u);
                    }
                }
            }
        }
Example #3
0
        public Task AddUserToGroup(string groupId, string userId)
        {
            if (Users.Count == 0)
            {
                throw new ArgumentException($"no users were preconfigured. Call 'PreConfigureUserInMock' to do so.");
            }

            if (!Users.Any(u => u.Id.Equals(userId)))
            {
                throw new ArgumentException($"user with id {userId} was not preconfigured. Call 'PreConfigureUserInMock' to do so.");
            }
            var user = Users.First(u => u.Id.Equals(userId));

            if (!UsersInGroup.ContainsKey(groupId))
            {
                UsersInGroup.Add(groupId, new List <string>()
                {
                    userId
                });
            }
            else
            {
                var group = UsersInGroup.First(g => g.Key.Equals(groupId));

                if (!group.Value.Any(id => id.Equals(userId)))
                {
                    ;
                }
                {
                    group.Value.Add(userId);
                }
            }
            return(Task.CompletedTask);
        }
Example #4
0
        public ShoutGroupPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator) : base(navigationService)
        {
            Button b  = new Button();
            var    x2 = (FileImageSource)ImageSource.FromFile("ic_coffee_outline_white_48dp.png");
            var    x1 = (FileImageSource)ImageSource.FromFile("ic_food_croissant_white_48dp.png");

            Icons.Add(x1);
            Icons.Add(x2);

            m_NavigationService   = navigationService;
            m_EventAggregator     = eventAggregator;
            CreateGroupCommand    = new DelegateCommand(OnCreateGroupCommand);
            AddUserToGroupCommand = new DelegateCommand(OnAddUserToGroupCommand);
            CancelCommand         = new DelegateCommand(OnCancelCommand);
            ClickColourCommand    = new Command <object>(OnClickColourCommand);
            ClickColour           = new DelegateCommand(OnClickColour);
            ClickIconCommand      = new Command <object>(OnClickIconCommand);
            ClickIcon             = new DelegateCommand(OnClickIcon);
            RemoveUserCommand     = new DelegateCommand <int?>(OnRemoveUserCommand);
            UsersInGroup.Add(new ShoutUserDto());
            Colours = MyColours;
        }
Example #5
0
 public void OnAddUserToGroupCommand()
 {
     UsersInGroup.Add(new ShoutUserDto());
     RaisePropertyChanged(nameof(UsersInGroup));
 }