Esempio n. 1
0
        private async void Register()
        {
            //TODO Do the API call take the response save the installation token
            if (await Permissions.CheckStatusAsync <Permissions.Phone>() == PermissionStatus.Granted)
            {
                _utility.GetAppId();
            }
            else
            {
                //will think the else one
            }
            RegisterModel register = new RegisterModel()
            {
                Name        = Name,
                Contact     = EmailorPhone,
                DeviceId    = App.DeviceId,
                DeviceModel = Xamarin.Essentials.DeviceInfo.Manufacturer + ", " + Xamarin.Essentials.DeviceInfo.Model,
                Password    = PassWord,
                Consent     = GetConsent(),
                DeviceType  = Xamarin.Essentials.DeviceInfo.Platform + "  " + Xamarin.Essentials.DeviceInfo.Idiom
            };

            //Commented just for development purpose
            //var response = await _webHelper.PostRegister(register);

            //remove this post development
            var response = new BaseResponse <RegistrationResponse> .Success()
            {
                data = new RegistrationResponse()
                {
                    InstallToken = "MockInstallToken",
                    UID          = 23323
                }
            };

            switch (response)
            {
            case BaseResponse <RegistrationResponse> .Success s:
                SaveToken(s.data.InstallToken);
                _navservice.Goto(new SensorData.Views.FirstPage(new CredModel
                {
                    deviceId = App.DeviceId,
                    password = PassWord,
                    username = Name
                }));
                break;

            //Commented just for development purpose
            //case BaseResponse<RegistrationResponse>.Error e:
            //    var res = await _navservice.ShowInteractiveDialogAsync("Sorry", "Sorry we are experiencing some trouble. Please try again " +
            //        "after sometime or Contact us", "Call Us", "Cancel");
            //    if (res)
            //    {
            //        //Open the phone dialer
            //    }
            //    break;
            default:
                break;
            }
        }
Esempio n. 2
0
        public FirstPageViewModel(INavService navService, ICache cache, IWebHelper webHelper)
        {
            _navService = navService;
            _cache      = cache;
            _webHelper  = webHelper;

            LoginCommand       = new Command(Login);
            FingerPrintCommand = new Command(FingerPrintLoginAsync);
            RegisterCommand    = new Command(() => _navService.Goto(new NavigationPage(new SensorData.Views.Registration())));
        }