Beispiel #1
0
        private void OnSelectPostTypes(object param)
        {
            if (param is PostTypeDataItem postTypeDataItem)
            {
                ClosePopupCommand.Execute(null);

                NavigationService.NavigateToAsync <NewPostViewModel>(postTypeDataItem.PostType);
            }
        }
Beispiel #2
0
        private async Task CreateProject()
        {
            try
            {
                List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("Title", Title_),
                    new KeyValuePair <string, string>("Project Type", TypeText),
                    new KeyValuePair <string, string>("Project Status", StatusText),
                    new KeyValuePair <string, string>("Address", Address)
                };
                if (FieldValidation.ValidateFields(values))
                {
                    CanSaveProject = false;

                    ProjectModel projectData = new ProjectModel()
                    {
                        Title         = Title_,
                        ProjectTypeID = SelectedType?.ID,
                        Type          = SelectedType == null ? new TypeModel {
                            Title = TypeText, CreatedBy = ProjectSelection.LoggedInUser.Name
                        } : null,
                        ProjectStatusID = SelectedStatus?.ID,
                        Status          = SelectedStatus == null ? new StatusModel {
                            Title = StatusText, CreatedBy = ProjectSelection.LoggedInUser.Name
                        } : null,
                        StartDate = StartDate,
                        DueDate   = DueDate,
                        Address   = Address,
                        CreatedBy = ProjectSelection.LoggedInUser.Name,
                        CreatedOn = DateTime.Now
                    };

                    HttpResponseMessage result = await apiHelper.PostProject(ProjectSelection.LoggedInUser.Token, projectData).ConfigureAwait(false);

                    if (result.IsSuccessStatusCode)
                    {
                        MessageBox.Show($"Project Saved Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                        Application.Current.Dispatcher.Invoke((Action) delegate
                        {
                            new Action(async() => await ProjectSelection.GetProjects(null))();
                            ClosePopupCommand.Execute(null);
                        });
                    }
                    else
                    {
                        MessageBox.Show("Error in saving Project", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    CanSaveProject = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                CanSaveProject = true;
            }
        }
Beispiel #3
0
        private async void OnDelete()
        {
            await _announcementService.DeleteAnnounceAsync(SelectedPostBaseViewModel.Post.AnnounceBody.Id, new CancellationTokenSource());

            ClosePopupCommand.Execute(null);

            if (NavigationService.CurrentViewModelsNavigationStack.Count > 1)
            {
                await NavigationService.GoBackAsync();
            }
        }
        protected async override void OnAddMemberToTheClique()
        {
            Guid busyKey = Guid.NewGuid();

            UpdateBusyVisualState(busyKey, true);

            ResetCancellationTokenSource(ref _inviteMemberToTheTeamCancellationTokenSource);
            CancellationTokenSource cancellationTokenSource = _inviteMemberToTheTeamCancellationTokenSource;

            try {
                Tuple <List <ProfileDTO>, string> inviteResult = await _inviteService.AddMembersToTheTeamByTeamIdAsync(_targetTeam.Id, PossibleGroupMembers.Select <ProfileDTO, long>((pDTO) => pDTO.Id), cancellationTokenSource);

                if (string.IsNullOrEmpty(inviteResult.Item2) || string.IsNullOrWhiteSpace(inviteResult.Item2))
                {
                    await DialogService.ToastAsync(AddMemberToTeamPopupViewModel._TEAM_INVITE_HAS_BEEN_SENT_MESSAGE);

                    await((ContentPageBaseViewModel)NavigationService.LastPageViewModel).InitializeAsync(new MembersAttachedToTheTeamArgs()
                    {
                        AttachedMembers = inviteResult.Item1
                    });

                    ClosePopupCommand.Execute(null);
                }
                else
                {
                    await DialogService.ToastAsync(inviteResult.Item2);

                    if (inviteResult.Item1.Any())
                    {
                        PossibleGroupMembers = PossibleGroupMembers
                                               .Except <ProfileDTO>(PossibleGroupMembers.Where <ProfileDTO>((pDTO) => inviteResult.Item1.Any(invitedPDTO => invitedPDTO.Id == pDTO.Id)))
                                               .ToObservableCollection();

                        await((ContentPageBaseViewModel)NavigationService.LastPageViewModel).InitializeAsync(new MembersAttachedToTheTeamArgs()
                        {
                            AttachedMembers = inviteResult.Item1
                        });
                    }
                }
            }
            catch (OperationCanceledException) { }
            catch (ObjectDisposedException) { }
            catch (ServiceAuthenticationException) { }
            catch (Exception exc) {
                Crashes.TrackError(exc);

                await DialogService.ToastAsync(exc.Message);
            }

            UpdateBusyVisualState(busyKey, false);
        }
Beispiel #5
0
 private void SearchTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter && UseManualSearch && ManualSearchCommand != null && ManualSearchCommand.CanExecute(null))
     {
         if (!IsPopUpOpen)
         {
             IsPopUpOpen = true;
         }
         ManualSearchCommand.Execute(null);
     }
     else if (e.Key == Key.Enter && Results != null && Results.Count == 1 && SingleResultEnterCommand != null && SingleResultEnterCommand.CanExecute(Results[0]))
     {
         SingleResultEnterCommand.Execute(Results[0]);
         if (ClosePopupCommand.CanExecute(null))
         {
             ClosePopupCommand.Execute(null);
         }
     }
 }
Beispiel #6
0
        protected async override void OnAddMemberToTheClique()
        {
            Guid busyKey = Guid.NewGuid();

            UpdateBusyVisualState(busyKey, true);

            ResetCancellationTokenSource(ref _attachMembersToTheGroupCancellationTokenSource);
            CancellationTokenSource cancellationTokenSource = _attachMembersToTheGroupCancellationTokenSource;

            try {
                List <MemberDTO> attachedMembers = await _groupsService.InviteMemberToTheGroupAsync(new InviteMembersToTheGroupDataModel()
                {
                    ProfileId  = GlobalSettings.Instance.UserProfile.Id,
                    GroupId    = _targetGroup.Id,
                    MembersIds = PossibleGroupMembers.Select <ProfileDTO, long>(pDTO => pDTO.Id).ToArray <long>()
                }, cancellationTokenSource);

                if (attachedMembers != null && attachedMembers.Any())
                {
                    await DialogService.ToastAsync(_GROUP_INVITE_HAS_BEEN_SENT_MESSAGE);

                    ///
                    /// TODO: use appropriate messaging event (remove old approach)
                    ///
                    await((ContentPageBaseViewModel)NavigationService.LastPageViewModel).InitializeAsync(new MembersAttachedToTheGroupArgs()
                    {
                        AttachedMembers = attachedMembers
                    });

                    ClosePopupCommand.Execute(null);
                }
            }
            catch (OperationCanceledException) { }
            catch (ObjectDisposedException) { }
            catch (ServiceAuthenticationException) { }
            catch (Exception exc) {
                Crashes.TrackError(exc);

                await DialogService.ToastAsync(exc.Message);
            }

            UpdateBusyVisualState(busyKey, false);
        }