예제 #1
0
        public ShowContentViewModel(IODataClient oDataClient, IUserDialogs userDialogs, INewsService newsService)
        {
            _oDataClient = oDataClient;
            _userDialogs = userDialogs;
            _newsService = newsService;


            Like = new BitDelegateCommand(async() =>
            {
                using (_userDialogs.Loading(ConstantStrings.Loading))
                {
                    bool likeStatus = Content.YourLike;

                    Content.YourLike = await newsService.LikeNews(Content.NewsID);

                    if (Content.YourLike == false && likeStatus == true)
                    {
                        Content.Likes--;
                    }
                    else if (Content.YourLike == true && likeStatus == false)
                    {
                        Content.Likes++;
                    }
                }
            });

            ShareCommand = new BitDelegateCommand(async() =>
            {
                await Share.RequestAsync(new ShareTextRequest
                {
                    Text  = NewsService.StripHTML(Content.Text),
                    Title = Content.Title
                });
            });
        }
 public CalculatorViewModel()
 {
     DoSumCommand            = new BitDelegateCommand(DoSum);
     DoSubtractionCommand    = new BitDelegateCommand(DoSubtraction);
     DoMultiplicationCommand = new BitDelegateCommand(DoMultiplication);
     DoDivisionCommand       = new BitDelegateCommand(DoDivision);
 }
예제 #3
0
 public OpenImagePopupViewModel()
 {
     GoBack = new BitDelegateCommand(async() =>
     {
         await NavigationService.GoBackAsync();
     });
 }
예제 #4
0
 public TestViewModel()
 {
     CloseCommand              = new BitDelegateCommand(Close);
     ThrowExceptionCommand     = new BitDelegateCommand(ThrowException);
     IncreaseStepsCountCommand = new BitDelegateCommand(IncreaseSteps);
     TestSignalrCommand        = new BitDelegateCommand(TestSignalr);
 }
예제 #5
0
 public TestViewModel(IPopupNavigationService popupNavigationService)
 {
     Close = new BitDelegateCommand(async() =>
     {
         await popupNavigationService.PopAsync();
     });
 }
예제 #6
0
        public ContactUsViewModel()
        {
            WhatsApp = new BitDelegateCommand(async() =>
            {
                Device.OpenUri(new System.Uri("https://api.whatsapp.com/send?phone=989036193862"));
            });

            Telegram = new BitDelegateCommand(async() =>
            {
                Device.OpenUri(new System.Uri("https://t.me/mo-kml"));
            });

            Instagram = new BitDelegateCommand(async() =>
            {
                Device.OpenUri(new System.Uri("https://www.instagram.com/mo_kml/"));
            });

            Call = new BitDelegateCommand(async() =>
            {
                Device.OpenUri(new System.Uri("tel:038773729"));
            });

            Route = new BitDelegateCommand(async() =>
            {
                Device.OpenUri(new System.Uri("geo:35.71022,51.4939886"));
            });
        }
예제 #7
0
        public MenuViewModel(ISecurityService securityService, IEventAggregator eventAggregator)
        {
            GoToPage = new BitDelegateCommand<string>(async (page) =>
            {
                eventAggregator.GetEvent<ToggleMenuEvent>().Publish(Menu);

                await NavigationService.NavigateAsync(page);
            });

            Logout = new BitDelegateCommand(async () =>
            {
                eventAggregator.GetEvent<ToggleMenuEvent>().Publish(Menu);

                await securityService.Logout();
                await NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(LoginView)}");
            });

            GoBack = new BitDelegateCommand(async () =>
              {
                  eventAggregator.GetEvent<ToggleMenuEvent>().Publish(Menu);

                  await NavigationService.GoBackAsync();
              });

        }
 public CustomersViewModel()
 {
     LoadMoreCommand = new BitDelegateCommand(LoadMore);
     AddCommand      = new BitDelegateCommand(Save);
     EditCommand     = new BitDelegateCommand <CustomerDto>(Save);
     DeleteCommand   = new BitDelegateCommand <CustomerDto>(Delete);
 }
예제 #9
0
 public MenuViewModel()
 {
     AddNewGroupCommand = new BitDelegateCommand(AddNewGroupAsync, () => !string.IsNullOrEmpty(NewGroupName));
     AddNewGroupCommand.ObservesProperty(() => NewGroupName);
     CancelAddNewGroupCommand = new BitDelegateCommand(CancelAddNewGroupAsync);
     ShowNewGroupStackCommand = new BitDelegateCommand(async() => { NewGroupName = Strings.NewGroupName; });
 }
        public EvaluationRequestListViewModel(IEvlRequestService evlRequestService, IUserDialogs userDialogs, IPageDialogService dialogService, IEventAggregator eventAggregator)
        {
            _evlRequestService = evlRequestService;
            _userDialogs       = userDialogs;
            _dialogService     = dialogService;
            _eventAggregator   = eventAggregator;

            ShowRequestProgress = new BitDelegateCommand <EvlRequestListItemSource>(async(request) =>
            {
                await NavigationService.NavigateAsync(nameof(EvlRequestProgressView), new NavigationParameters
                {
                    { nameof(EvlRequestListItemSource), request }
                });
            });

            OpenInquiryBox = new BitDelegateCommand(async() =>
            {
                eventAggregator.GetEvent <OpenInquiryPopupEvent>().Publish(new OpenInquiryPopupEvent());
            });

            Inquiry = new BitDelegateCommand(async() =>
            {
                inquiryCancellationTokenSource?.Cancel();
                inquiryCancellationTokenSource = new CancellationTokenSource();
                using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: inquiryCancellationTokenSource.Cancel))
                {
                    if (string.IsNullOrEmpty(DocumentNumber) || !Requests.Any(r => r.Code == int.Parse(DocumentNumber)))
                    {
                        await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.DocumentNumberIsInvalid, ConstantStrings.Ok);
                        DocumentNumber = null;
                        return;
                    }

                    EvlRequestDto requestDto = await evlRequestService.SearchByCode(int.Parse(DocumentNumber));

                    if (requestDto == null)
                    {
                        await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.RequestDosentExist, ConstantStrings.Ok);
                        DocumentNumber = null;
                        return;
                    }
                    else
                    {
                        DocumentNumber = null;

                        eventAggregator.GetEvent <OpenInquiryPopupEvent>().Publish(new OpenInquiryPopupEvent());

                        INavigationParameters parameter = new NavigationParameters();
                        parameter.Add(nameof(EvlRequestListItemSource), new EvlRequestListItemSource
                        {
                            Code            = requestDto.Code,
                            RequestId       = requestDto.Id,
                            RequestTypeName = EnumHelper <EvlRequestType> .GetDisplayValue(requestDto.EvlRequestType)
                        });

                        await NavigationService.NavigateAsync(nameof(EvlRequestProgressView), parameter);
                    }
                }
            });
        }
        public EvaluationRequestLostDetailViewModel(
            IUserDialogs userDialogs,
            ILicenseHelper licenseHelper,
            ISanaapAppTranslateService translateService,
            IEvlRequestValidator evlRequestValidator,
            IInitialDataService initialDataService,
            IPageDialogService dialogService)
        {
            _initialDataService = initialDataService;
            _userDialogs        = userDialogs;
            _licenseHelper      = licenseHelper;

            GoBack = new BitDelegateCommand(async() =>
            {
                await NavigationService.GoBackAsync();
            });

            GoToNextLevel = new BitDelegateCommand(async() =>
            {
                requestCancellationTokenSource?.Cancel();
                requestCancellationTokenSource = new CancellationTokenSource();

                using (userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: requestCancellationTokenSource.Cancel))
                {
                    if (SelectedCar == null)
                    {
                        await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.CarIsNull, ConstantStrings.Ok);
                        return;
                    }
                    if (SelectedAlphabet == null)
                    {
                        await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.NumberPlateIsNotValid, ConstantStrings.Ok);
                        return;
                    }

                    Request.LostCarId = SelectedCar.PrmID;

                    LostLicense.Alphabet = SelectedAlphabet.Name;
                    if (licenseHelper.ConvertToPlateNumber(LostLicense, out string licensePlate))
                    {
                        Request.LostPlateNumber = licensePlate;
                    }
                    else
                    {
                        return;
                    }

                    if (!evlRequestValidator.IsLostDetailValid(Request, out string message))
                    {
                        await dialogService.DisplayAlertAsync(string.Empty, translateService.Translate(message), ConstantStrings.Ok);
                        return;
                    }

                    await NavigationService.NavigateAsync(nameof(EvaluationRequestDescriptionView), new NavigationParameters
                    {
                        { nameof(Request), Request }
                    });
                }
            });
        }
예제 #12
0
        public EvlRequestWaitViewModel(
            IODataClient odataClient,
            IEvlRequestService evlRequestService,
            IDeviceService deviceService,
            IODataClient oDataClient,
            HttpClient httpClient,
            IDateTimeUtils dateTimeUtils,
            IInitialDataService initialDataService,
            IPageDialogService pageDialogService)
        {
            _odataClient        = odataClient;
            _evlRequestService  = evlRequestService;
            _pageDialogService  = pageDialogService;
            _initialDataService = initialDataService;
            _httpClient         = httpClient;
            _dateTimeUtils      = dateTimeUtils;

            GoToMain = new BitDelegateCommand(async() =>
            {
                await NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(MainMenuView)}");
            });

            Call = new BitDelegateCommand(async() =>
            {
                deviceService.OpenUri(new Uri("tel://" + ExpertMobileNo + ""));
            });

            //RatingValueChanged = new BitDelegateCommand<int>(async (value) =>
            //{
            //    await _pageDialogService.DisplayAlertAsync("", "RatingValueChanged : " + value.ToString(), ErrorMessages.Ok);
            //});
        }
예제 #13
0
        public EvaluationRequestMapViewModel(IUserDialogs userDialogs, IPageDialogService dialogService)
        {
            _userDialogs   = userDialogs;
            _dialogService = dialogService;

            UpdateLocation = new BitDelegateCommand <Xamarin.Forms.GoogleMaps.Map>(async(map) =>
            {
                Position centerPosition = map.VisibleRegion.Center;

                Request.Latitude  = centerPosition.Latitude;
                Request.Longitude = centerPosition.Longitude;

                //Geocoder geoCoder = new Geocoder();
                //Request.Address = (await geoCoder.GetAddressesForPositionAsync(centerPosition)).FirstOrDefault();

                await NavigationService.NavigateAsync(nameof(EvaluationRequestFilesView), new NavigationParameters
                {
                    { nameof(Request), Request }
                });
            });

            GoBack = new BitDelegateCommand(async() =>
            {
                await NavigationService.GoBackAsync();
            });
        }
예제 #14
0
 public CommentAnswerPopupViewModel()
 {
     ClosePopup = new BitDelegateCommand(async() =>
     {
         await NavigationService.GoBackAsync();
     });
 }
예제 #15
0
        public InsuranceListPopupViewModel(IEventAggregator eventAggregator, IPolicyService policyService, IUserDialogs userDialogs)
        {
            _policyService = policyService;
            _userDialogs   = userDialogs;

            EvlRequestItemSource _request = new EvlRequestItemSource();

            SubscriptionToken = eventAggregator.GetEvent <InsuranceEvent>().SubscribeAsync(async(request) =>
            {
                _request = request;

                insuranceCancellationTokenSource?.Cancel();
                insuranceCancellationTokenSource = new CancellationTokenSource();

                using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: insuranceCancellationTokenSource.Cancel))
                {
                    await loadInsurances();
                }
            }, keepSubscriberReferenceAlive: true, threadOption: ThreadOption.UIThread);

            SelectPolicy = new BitDelegateCommand <PolicyItemSource>(async(policy) =>
            {
                eventAggregator.GetEvent <OpenInsurancePopupEvent>().Publish(new OpenInsurancePopupEvent());

                //await NavigationService.NavigateAsync(nameof(EvaluationRequestView), new NavigationParameters {
                //    { "Insurance",policy},
                //    {nameof(EvlRequestItemSource),_request }
                //});
            });
        }
예제 #16
0
 public MainViewModel()
 {
     SyncCommand             = new BitDelegateCommand(Sync);
     SendHttpRequestCommand  = new BitDelegateCommand(SendHttpRequest);
     SendODataRequestCommand = new BitDelegateCommand(SendODataRequest);
     LogoutCommand           = new BitDelegateCommand(Logout);
     ShowPopupCommand        = new BitDelegateCommand(ShowPopup);
 }
예제 #17
0
 public LoginViewModel()
 {
     LoginUsingCredentialsCommand = new BitDelegateCommand(LoginUsingCredentials, () => !string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password));
     LoginUsingCredentialsCommand.ObservesProperty(() => UserName);
     LoginUsingCredentialsCommand.ObservesProperty(() => Password);
     LoginUsingBrowserCommand    = new BitDelegateCommand(LoginUsingBrowser);
     LoginUsingGooglePlusCommand = new BitDelegateCommand(LoginUsingGooglePlus);
     SkipCommand = new BitDelegateCommand(Skip);
 }
예제 #18
0
 public MenuViewModel()
 {
     BeginAddNewGroupCommand = new BitDelegateCommand(BeginAddNewGroup);
     AddNewGroupCommand      = new BitDelegateCommand(AddNewGroupAsync, () => !string.IsNullOrEmpty(NewGroupTitle));
     AddNewGroupCommand.ObservesProperty(() => NewGroupTitle);
     DeleteGroupCommand       = new BitDelegateCommand <ToDoGroupDto>(DeleteGroupAsync);
     EditGroupNameCommand     = new BitDelegateCommand <ToDoGroupDto>(EditGroupNameAsync);
     CancelAddNewGroupCommand = new BitDelegateCommand(CancelAddNewGroupAsync);
     OpenToDoItemsCommand     = new BitDelegateCommand <object>(OpenToDoItems);
 }
예제 #19
0
        public SampleViewModel(IDateHelper dateHelper, IUserDialogs userDialogs)
        {
            _dateHelper = dateHelper;
            registerCancellationTokenSource?.Cancel();
            registerCancellationTokenSource = new CancellationTokenSource();

            Select = new BitDelegateCommand(async() =>
            {
                await NavigationService.NavigateAsync(nameof(EvaluationRequestExpertRankView));
            });
            //Contents = new ObservableCollection<Test>(
            //    new List<Test>
            //    {
            //        new Test{ Image=ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Title="مغفول ماندن بیمه رانندگان طی چند سال اخیر", Text="مدیرعامل اتحادیه تاکسیرانی های شهری  کشور گفت : متاسفانه موضوع بسیار مهم تامین اجتماعی رانندگان طی چند سال اخیر مغفول مانده، در صورتی ",Likes=125,YourLike=1,Date="1397/10/23"},
            //        new Test{ Image=ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Title="مغفول ماندن بیمه رانندگان طی چند سال اخیر", Text="مدیرعامل اتحادیه تاکسیرانی های شهری  کشور گفت : متاسفانه موضوع بسیار مهم تامین اجتماعی رانندگان طی چند سال اخیر مغفول مانده، در صورتی ",Likes=225,YourLike=0,Date="1397/10/23"},
            //        new Test{ Image=ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Title="مغفول ماندن بیمه رانندگان طی چند سال اخیر", Text="مدیرعامل اتحادیه تاکسیرانی های شهری  کشور گفت : متاسفانه موضوع بسیار مهم تامین اجتماعی رانندگان طی چند سال اخیر مغفول مانده، در صورتی ",Likes=345,YourLike=0,Date="1397/10/23"},
            //        new Test{ Image=ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Title="مغفول ماندن بیمه رانندگان طی چند سال اخیر", Text="مدیرعامل اتحادیه تاکسیرانی های شهری  کشور گفت : متاسفانه موضوع بسیار مهم تامین اجتماعی رانندگان طی چند سال اخیر مغفول مانده، در صورتی ",Likes=120,YourLike=1,Date="1397/10/23"},
            //        new Test{ Image=ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Title="مغفول ماندن بیمه رانندگان طی چند سال اخیر", Text="مدیرعامل اتحادیه تاکسیرانی های شهری  کشور گفت : متاسفانه موضوع بسیار مهم تامین اجتماعی رانندگان طی چند سال اخیر مغفول مانده، در صورتی ",Likes=54,YourLike=0 ,Date="1397/10/23"}
            //    }
            //    );

            //Image = ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")),

            Contents = new ObservableCollection <Test>(

                new List <Test>
            {
                new Test {
                    Image = ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Likes = 157, Date = "1397/11/17", Text = "متنی برای آزمایش میزان درستی قرار گیری اشیاء در کنار یکدیگر این یک متن آزمایشی است و این موضوع صرفا جهت طولانی تر شدن متن بوده و دلیل دیگری ندارد", Title = "عنوان آزمایشی برای برسی چگونگی قرارگیری اشیاء در کنار یکدیگر", YourLike = 1
                },
                new Test {
                    Image = ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Likes = 137, Date = "1397/11/17", Text = "متنی برای آزمایش میزان درستی قرار گیری اشیاء در کنار یکدیگر این یک متن آزمایشی است و این موضوع صرفا جهت طولانی تر شدن متن بوده و دلیل دیگری ندارد", Title = "عنوان آزمایشی برای برسی چگونگی قرارگیری اشیاء در کنار یکدیگر", YourLike = 0
                },
                new Test {
                    Image = ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Likes = 155, Date = "1397/11/17", Text = "متنی برای آزمایش میزان درستی قرار گیری اشیاء در کنار یکدیگر این یک متن آزمایشی است و این موضوع صرفا جهت طولانی تر شدن متن بوده و دلیل دیگری ندارد", Title = "عنوان آزمایشی برای برسی چگونگی قرارگیری اشیاء در کنار یکدیگر", YourLike = 1
                },
                new Test {
                    Image = ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Likes = 457, Date = "1397/11/17", Text = "متنی برای آزمایش میزان درستی قرار گیری اشیاء در کنار یکدیگر این یک متن آزمایشی است و این موضوع صرفا جهت طولانی تر شدن متن بوده و دلیل دیگری ندارد", Title = "عنوان آزمایشی برای برسی چگونگی قرارگیری اشیاء در کنار یکدیگر", YourLike = 1
                },
                new Test {
                    Image = ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Likes = 127, Date = "1397/11/17", Text = "متنی برای آزمایش میزان درستی قرار گیری اشیاء در کنار یکدیگر این یک متن آزمایشی است و این موضوع صرفا جهت طولانی تر شدن متن بوده و دلیل دیگری ندارد", Title = "عنوان آزمایشی برای برسی چگونگی قرارگیری اشیاء در کنار یکدیگر", YourLike = 0
                },
                new Test {
                    Image = ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Likes = 156, Date = "1397/11/17", Text = "متنی برای آزمایش میزان درستی قرار گیری اشیاء در کنار یکدیگر این یک متن آزمایشی است و این موضوع صرفا جهت طولانی تر شدن متن بوده و دلیل دیگری ندارد", Title = "عنوان آزمایشی برای برسی چگونگی قرارگیری اشیاء در کنار یکدیگر", YourLike = 0
                },
                new Test {
                    Image = ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Likes = 257, Date = "1397/11/17", Text = "متنی برای آزمایش میزان درستی قرار گیری اشیاء در کنار یکدیگر این یک متن آزمایشی است و این موضوع صرفا جهت طولانی تر شدن متن بوده و دلیل دیگری ندارد", Title = "عنوان آزمایشی برای برسی چگونگی قرارگیری اشیاء در کنار یکدیگر", YourLike = 1
                },
                new Test {
                    Image = ImageSource.FromUri(new Uri("https://img.game.co.uk/ml2/7/3/0/3/730331_scr3_a.png")), Likes = 187, Date = "1397/11/17", Text = "متنی برای آزمایش میزان درستی قرار گیری اشیاء در کنار یکدیگر این یک متن آزمایشی است و این موضوع صرفا جهت طولانی تر شدن متن بوده و دلیل دیگری ندارد", Title = "عنوان آزمایشی برای برسی چگونگی قرارگیری اشیاء در کنار یکدیگر", YourLike = 1
                },
            });

            Image = "https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_3.jpg";
        }
예제 #20
0
 public MainViewModel()
 {
     SyncCommand                  = new BitDelegateCommand(Sync);
     SendHttpRequestCommand       = new BitDelegateCommand(SendHttpRequest);
     SendRefitRequestCommand      = new BitDelegateCommand(SendRefitRequest);
     SendODataRequestCommand      = new BitDelegateCommand(SendODataRequest);
     SendODataBatchRequestCommand = new BitDelegateCommand(SendODataBatchRequest);
     LogoutCommand                = new BitDelegateCommand(Logout);
     ShowPopupCommand             = new BitDelegateCommand(ShowPopup);
     OpenConsoleCommand           = new BitDelegateCommand(OpenConsole);
 }
예제 #21
0
        public EvlRequestProgressViewModel(IEvlRequestService evlRequestService, IUserDialogs userDialogs, IDateHelper dateHelper)
        {
            _evlRequestService = evlRequestService;
            _userDialogs       = userDialogs;
            _dateHelper        = dateHelper;

            ClosePopup = new BitDelegateCommand(async() =>
            {
                await NavigationService.GoBackAsync();
            });
        }
예제 #22
0
        public MainMenuViewModel(
            ISecurityService securityService, IDeviceService deviceService, IUserDialogs userDialogs, HttpClient httpClient, IInitialDataService initialDataService)
        {
            _userDialogs        = userDialogs;
            _httpClient         = httpClient;
            _initialDataService = initialDataService;

            GoToEvalutionRequestMenu = new BitDelegateCommand(async() =>
            {
                await NavigationService.NavigateAsync(nameof(EvaluationRequestMenuView));
            });
        }
예제 #23
0
        public EvaluationRequestExpertRankViewModel(IEvlRequestService requestService)
        {
            SubmitRank = new BitDelegateCommand(async() =>
            {
                if (Request.RankValue != 0 || !string.IsNullOrEmpty(Request.RankDescription))
                {
                    await requestService.UpdateRank(Request);
                }

                await NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(MainMenuView)}");
            });
        }
예제 #24
0
파일: App.xaml.cs 프로젝트: mo-kml/Sanaap
        public App(IPlatformInitializer initializer)
            : base(initializer)
        {
            InitializeComponent();

            OpenMenu = new BitDelegateCommand <IconButton>(async(button) =>
            {
                AbsoluteLayout menu = ((AbsoluteLayout)button.BindingContext);

                ToggleMenu(menu);
            });
        }
예제 #25
0
        public LoginViewModel(INavigationService navigationService, IODataClient oDataClient, HttpClient httpClient, IPageDialogService pageDialogService, ISecurityService securityService)
        {
            LoginUsingCredentionals = new BitDelegateCommand(async() =>
            {
                try
                {
                    await securityService.LoginWithCredentials(UserName, Password, client_id: "TestResOwner", client_secret: "secret");
                    await navigationService.NavigateAsync("/Nav/Main");
                }
                catch
                {
                    await pageDialogService.DisplayAlertAsync("Login failed", "Login failed", "Ok");
                    throw;
                }
            }, () => !string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password));

            LoginUsingCredentionals.ObservesProperty(() => UserName);
            LoginUsingCredentionals.ObservesProperty(() => Password);

            LoginUsingGooglePlus = new BitDelegateCommand(async() =>
            {
                try
                {
                    await securityService.Login(new { SignInType = "Google" });
                    await navigationService.NavigateAsync("/Nav/Main");
                }
                catch
                {
                    await pageDialogService.DisplayAlertAsync("Login failed", "Login failed", "Ok");
                    throw;
                }
            });

            LoginUsingBrowser = new BitDelegateCommand(async() =>
            {
                try
                {
                    await securityService.Login();
                    await navigationService.NavigateAsync("/Nav/Main");
                }
                catch
                {
                    await pageDialogService.DisplayAlertAsync("Login failed", "Login failed", "Ok");
                    throw;
                }
            });

            Skip = new BitDelegateCommand(async() =>
            {
                await navigationService.NavigateAsync("/Nav/Main");
            });
        }
예제 #26
0
        public ContentListViewModel(IODataClient oDataClient, IUserDialogs userDialogs, INewsService newsService, IInitialDataService initialDataService, IEventAggregator eventAggregator, IPageDialogService dialogService)
        {
            _oDataClient        = oDataClient;
            _userDialogs        = userDialogs;
            _newsService        = newsService;
            _initialDataService = initialDataService;

            ShowContent = new BitDelegateCommand <NewsItemSource>(async(content) =>
            {
                INavigationParameters parameters = new NavigationParameters();
                parameters.Add("NewsId", content.NewsID);

                await NavigationService.NavigateAsync(nameof(ShowContentView), parameters);
            });

            FilterContent = new BitDelegateCommand(async() =>
            {
                FilterDto.Month = SelectedMonth?.Number;
                FilterDto.Year  = SelectedYear?.Number;

                if (FilterDto.Month != null || FilterDto.Year != null)
                {
                    if (FilterDto.Month == null || FilterDto.Year == null)
                    {
                        await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.NewsFilterNotValid, ConstantStrings.Ok);

                        SelectedYear  = null;
                        SelectedMonth = null;

                        return;
                    }
                }

                contentCancellationTokenSource?.Cancel();
                contentCancellationTokenSource = new CancellationTokenSource();
                using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: contentCancellationTokenSource.Cancel))
                {
                    await loadContents(FilterDto);
                }

                eventAggregator.GetEvent <OpenNewsFilterPopupEvent>().Publish(new OpenNewsFilterPopupEvent());

                FilterDto     = new FilterNewsDto();
                SelectedYear  = null;
                SelectedMonth = null;
            });

            OpenFilterPopup = new BitDelegateCommand(async() =>
            {
                eventAggregator.GetEvent <OpenNewsFilterPopupEvent>().Publish(new OpenNewsFilterPopupEvent());
            });
        }
        public EvaluationRequestWaitViewModel(IEvlRequestService evlRequestService, IPageDialogService dialogService)
        {
            _evlRequestService = evlRequestService;
            _dialogService     = dialogService;

            Cancel = new BitDelegateCommand(async() =>
            {
                if (await dialogService.DisplayAlertAsync(string.Empty, ConstantStrings.AreYouSureToCancel, ConstantStrings.Yes, ConstantStrings.No))
                {
                    await NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(MainMenuView)}");
                }
            });
        }
예제 #28
0
 public MainViewModel()
 {
     SyncCommand            = new BitDelegateCommand(Sync);
     SendHttpRequestCommand = new BitDelegateCommand(SendHttpRequest);
     SendHttpRequestUsingGeneratedCodeCommand = new BitDelegateCommand(SendHttpRequestUsingGeneratedCode);
     SendRefitRequestCommand      = new BitDelegateCommand(SendRefitRequest);
     SendODataRequestCommand      = new BitDelegateCommand(SendODataRequest);
     SendODataBatchRequestCommand = new BitDelegateCommand(SendODataBatchRequest);
     LogoutCommand      = new BitDelegateCommand(Logout);
     ShowPopupCommand   = new BitDelegateCommand(ShowPopup);
     OpenConsoleCommand = new BitDelegateCommand(OpenConsole);
     GoToSampleCommand  = new BitDelegateCommand(GoToSample);
     RefreshPageCommand = new BitDelegateCommand(RefreshPage);
 }
예제 #29
0
        public MenuViewModel(INavigationService navigationService,
                             ISecurityService securityService)
        {
            GoToPage = new BitDelegateCommand <string>(async(page) =>
            {
                await navigationService.NavigateAsync(page);
            });

            Logout = new BitDelegateCommand(async() =>
            {
                await securityService.Logout();
                await navigationService.NavigateAsync("/Login");
            });
        }
예제 #30
0
        public LoginViewModel(
            ISecurityService securityService,
            ISanaapAppLoginValidator loginValidator,
            IPageDialogService pageDialogService,
            ISanaapAppTranslateService translateService,
            IUserDialogs userDialogs)
        {
            Login = new BitDelegateCommand(async() =>
            {
                registerCancellationTokenSource?.Cancel();
                registerCancellationTokenSource = new CancellationTokenSource();
                using (userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: registerCancellationTokenSource.Cancel))
                {
                    if (!loginValidator.IsValid(NationalCode, Mobile, out string errorMessage))
                    {
                        await pageDialogService.DisplayAlertAsync("", translateService.Translate(errorMessage), "باشه");
                        return;
                    }

                    try
                    {
                        await securityService.LoginWithCredentials(NationalCode, Mobile, "SanaapResOwner", "secret");
                        await NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(MainMenuView)}");
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("CustomerCouldNotBeFound"))
                        {
                            await pageDialogService.DisplayAlertAsync("", "کاربری با این مشخصات یافت نشد", "باشه");
                        }
                        else if (translateService.Translate(ex.GetMessage(), out string translateErrorMessage))
                        {
                            await pageDialogService.DisplayAlertAsync("", translateErrorMessage, "باشه");
                        }
                        else
                        {
                            string error = ex.ToString();
                            throw;
                        }
                    }
                }
            });

            Register = new BitDelegateCommand(async() =>
            {
                await NavigationService.NavigateAsync(nameof(RegisterView));
            });
        }