public void ToggleSendButton()
        {
            var isToAddressesCompleteChecked  = ToAddresses.Count(x => x.IsChecked) == ToAddresses.Count;
            var isCcAddressesCompleteChecked  = CcAddresses.Count(x => x.IsChecked) == CcAddresses.Count;
            var isBccAddressesCompleteChecked = BccAddresses.Count(x => x.IsChecked) == BccAddresses.Count;
            var isAlertsCompleteChecked       = Alerts.Count(x => x.IsChecked) == Alerts.Count;
            var isAttachmentsCompleteChecked  = Attachments.Count(x => x.IsChecked) == Attachments.Count;

            if (isToAddressesCompleteChecked && isCcAddressesCompleteChecked && isBccAddressesCompleteChecked &&
                isAlertsCompleteChecked && isAttachmentsCompleteChecked)
            {
                IsCanSendMail = true;
            }
            else
            {
                IsCanSendMail = false;
            }
        }
Esempio n. 2
0
        public AlertsViewModel(IAlertService alertService, IUserDialogs userDialogs,
                               IMvxMessenger mvxMessenger, AppHelper appHelper) : base(userDialogs, mvxMessenger, appHelper)
        {
            _alertService = alertService;

            ClearAlertsCommand = ReactiveCommand
                                 .CreateFromObservable <Unit, string>((param) =>
            {
                return(_appHelper.RequestConfirmation(AppResources.Alerts_Confirm_Clear)
                       .Do((_) => _userDialogs.ShowLoading(AppResources.Alerts_Deleting_Alerts))
                       .SelectMany((_) => string.IsNullOrEmpty(SonIdentity)
                                                 ? _alertService.ClearSelfAlerts() : _alertService.ClearAlertsOfSon(SonIdentity))
                       .Do((_) => _userDialogs.HideLoading()));
            });

            ClearAlertsCommand.Subscribe((alertsDeleted) =>
            {
                Debug.WriteLine("Alerts Deleted -> " + alertsDeleted);
                Alerts.Clear();
                DataFound = false;
            });

            ClearAlertsCommand.ThrownExceptions.Subscribe(HandleExceptions);

            RefreshCommand = ReactiveCommand
                             .CreateFromObservable <Unit, IList <AlertEntity> >((param) =>
            {
                if (PopupNavigation.PopupStack.Count > 0)
                {
                    PopupNavigation.PopAllAsync();
                }
                return(string.IsNullOrEmpty(SonIdentity) ?
                       alertService.GetSelfAlerts(CountAlertsOption.Value, AntiquityOfAlertsOption.Value, AlertLevelFilter) :
                       _alertService.GetAlertsBySon(SonIdentity, CountAlertsOption.Value, AntiquityOfAlertsOption.Value, AlertLevelFilter));
            });

            RefreshCommand.Subscribe((AlertsEntities) =>
            {
                Alerts.ReplaceRange(AlertsEntities);
                ResetCommonProps();
            });

            RefreshCommand.IsExecuting.Subscribe((IsLoading) => IsBusy = IsLoading);

            RefreshCommand.ThrownExceptions.Subscribe(HandleExceptions);

            DeleteAlertCommand = ReactiveCommand
                                 .CreateFromObservable <AlertEntity, string>((AlertEntity) =>
                                                                             alertService.DeleteAlertOfSon(AlertEntity.Son.Identity, AlertEntity.Identity)
                                                                             .Do((_) => Alerts.Remove(AlertEntity)));

            DeleteAlertCommand.IsExecuting.Subscribe((IsLoading) => IsBusy = IsLoading);

            DeleteAlertCommand.Subscribe((_) =>
            {
                _userDialogs.ShowSuccess(AppResources.Alerts_Deleted);

                if (Alerts.Count() == 0)
                {
                    DataFound = false;
                }
            });

            DeleteAlertCommand.ThrownExceptions.Subscribe(HandleExceptions);


            AllCategory.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == "IsFiltered")
                {
                    foreach (var category in AlertsLevelCategories)
                    {
                        category.IsEnabled = !AllCategory.IsFiltered;
                        if (AllCategory.IsFiltered)
                        {
                            category.IsFiltered = true;
                        }
                    }
                }
            };

            foreach (AlertCategoryModel AlertCategory in AlertsLevelCategories)
            {
                AlertCategory.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "IsFiltered")
                    {
                        var AlertCategoryModel = sender as AlertCategoryModel;
                        UpdateAlertFilter(AlertCategoryModel);
                    }
                };
            }
        }