public async Task Init(int lekarskoUverenjeId)
        {
            if (!Auth.IsAuthenticated())
            {
                NotificationService.Instance.Error(AppResources.UnauthenticatedAccessMessage);
                return;
            }

            _apiService.ChangeRoute(Routes.LekarskoUverenjeRoute);
            var getLekarskoUverenjeResult =
                await _apiService.GetById <LekarskoUverenjeDtoEL>(lekarskoUverenjeId, eagerLoaded : true);

            if (!getLekarskoUverenjeResult.Succeeded || !getLekarskoUverenjeResult.HasData)
            {
                NotificationService.Instance.Error(AppResources.ErrorWhenLoadingResourceMessage);
                return;
            }

            LekarskoUverenje = getLekarskoUverenjeResult.Data;

            _apiService.ChangeRoute(Routes.UputnicaRoute);
            var getUputnicaResult = await _apiService.Get <UputnicaDtoEL>(new UputnicaResourceParameters
            {
                EagerLoaded    = true,
                UputioDoktorId = LekarskoUverenje.Pregled.DoktorId,
                Datum          = LekarskoUverenje.Pregled.DatumPregleda
            });

            UputnicaId   = getUputnicaResult.Data?.FirstOrDefault()?.Id;
            UputnicaFlag = UputnicaId.HasValue;

            Id = LekarskoUverenje.Id;
            ZdravstvenoStanje = LekarskoUverenje.ZdravstvenoStanje.Opis;
            OpisStanja        = LekarskoUverenje.OpisStanja;
        }
Exemple #2
0
        public async Task ChangePassword()
        {
            if (!IsValidModel)
            {
                return;
            }
            IsBusy          = true;
            MainBodyVisible = false;

            _apiService.ChangeRoute($"{Routes.KorisniciRoute}/{Routes.ChangePasswordRoute}");
            var result = await _apiService.Post <int>(new ChangePasswordDto
            {
                CurrentPassword = OldPassword,
                NewPassword     = NewPassword
            });

            //Animation waiting
            await Task.Delay(2500);

            IsBusy = false;

            if (!result.Succeeded)
            {
                MainBodyVisible = true;
                NotificationService.Instance.Error(result.StatusCode == HttpStatusCode.BadRequest
                    ? result.Message
                    : AppResources.Error);
            }
            else
            {
                NotificationService.Instance.Success();
                await Application.Current.MainPage.PopToRootCurrentTabAsNavigationPage();
            }
        }
        public async Task FaceIDLogin()
        {
            //var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(
            //    new Plugin.Media.Abstractions.StoreCameraMediaOptions() { });

            var photo = await CrossMedia.Current.PickPhotoAsync();

            if (photo == null)
            {
                return;
            }

            IsBusy                = true;
            MainBodyVisible       = false;
            AnimationFrameVisible = true;

            SelfieForFaceID = photo.GetStream().AsByteArray();

            _apiService.ChangeRoute(Routes.PacijentiRoute);
            var result = await _apiService.Get <PacijentDtoEL>(new PacijentResourceParameters
            {
                EagerLoaded = true,
            });

            await Task.Delay(3500);

            if (!result.Succeeded || !result.HasData)
            {
                IsBusy                = false;
                MainBodyVisible       = true;
                AnimationFrameVisible = false;

                await Task.Delay(100);

                NotificationService.Instance.Error(AppResources.UnsuccessfullyAuthentication);
                return;
            }

            if (!await Auth.AuthenticateWithFaceID(SelfieForFaceID))
            {
                IsBusy                = false;
                MainBodyVisible       = true;
                AnimationFrameVisible = false;

                await Task.Delay(100);

                NotificationService.Instance.Error(AppResources.UnsuccessfullyAuthentication);
                return;
            }
            MainBodyVisible              = false;
            AnimationFrameVisible        = false;
            AnimationSuccessFrameVisible = true;
            await Task.Delay(2850);

            IsBusy = false;

            Application.Current.MainPage = new PacijentDasbhboardTabbedPage();
        }
        public async Task Init(int pregledId)
        {
            if (!Auth.IsAuthenticated())
            {
                NotificationService.Instance.Error(AppResources.UnauthenticatedAccessMessage);
                return;
            }

            _apiService.ChangeRoute(Routes.PreglediRoute);
            var getPregledResult =
                await _apiService.GetById <PregledDtoEL>(pregledId, eagerLoaded : true);

            if (!getPregledResult.Succeeded || !getPregledResult.HasData || getPregledResult.Data == null)
            {
                NotificationService.Instance.Error(AppResources.ErrorWhenLoadingResourceMessage);
                return;
            }
            Pregled = getPregledResult.Data;

            if (Pregled.IsOdradjen)
            {
                _apiService.ChangeRoute(Routes.LekarskoUverenjeRoute);
                var getLekarskoUverenjeResult = await _apiService.Get <LekarskoUverenjeDtoLL>(
                    new LekarskoUverenjeResourceParameters
                {
                    PregledId = pregledId
                });

                if (getLekarskoUverenjeResult.Succeeded && getLekarskoUverenjeResult.HasData)
                {
                    var lekarskoUverenje = getLekarskoUverenjeResult.Data.FirstOrDefault();
                    if (lekarskoUverenje != null)
                    {
                        LekarskoUverenjeId = lekarskoUverenje.Id;
                    }
                }
            }

            Id         = pregledId;
            Doktor     = Pregled.Doktor;
            DateTime   = Pregled.DatumPregleda;
            IsOdradjen = Pregled.IsOdradjen;
        }
        private async Task Register()
        {
            if (ProfilePicture == null)
            {
                return;
            }

            EnabledLoadingSpinner = true;
            IsBusy = true;
            if (!IsValidModel)
            {
                return;
            }

            _apiService.ChangeRoute(Routes.PacijentiRoute);
            var upsertDto = new PacijentUpsertDto
            {
                Ime     = Ime,
                Prezime = Prezime,
                BrojZdravstveneKnjizice = int.Parse(BrojKnjizice),
                JMBG            = JMBG,
                KorisnickiNalog = new KorisnickiNalogUpsertDto
                {
                    Username        = Username,
                    Password        = Password,
                    ConfirmPassword = ConfirmPassword
                },
                ProfilePicture = ProfilePictureAsBytes
            };

            var result = await _apiService.Post <PacijentDtoLL>(upsertDto);

            IsBusy = false;
            EnabledLoadingSpinner = false;

            if (result.Succeeded)
            {
                NotificationService.Instance.Success(AppResources.SuccessfullyCreatedAccount);
                await Task.Delay(100);

                if (await Auth.AuthenticateWithPassword(upsertDto.KorisnickiNalog.Username, upsertDto.KorisnickiNalog.Password))
                {
                    Application.Current.MainPage = new PacijentDasbhboardTabbedPage();
                }
            }
            else
            {
                NotificationService.Instance.Error(result.StatusCode == HttpStatusCode.BadRequest
                    ? result.Message
                    : string.Empty);
            }
        }
Exemple #6
0
        public async Task CheckPassword()
        {
            if (!ValidInput())
            {
                NotificationService.Instance.Toast("Neispravan unos");
                return;
            }

            _apiService.ChangeRoute($"{Routes.KorisniciRoute}/{Routes.CheckPasswordRoute}");

            var result = await _apiService.Post <int>(Password);

            if (!result.Succeeded && result.StatusCode == HttpStatusCode.BadRequest)
            {
                NotificationService.Instance.Error(result.Message);
                return;
            }

            CommandToExecute?.Execute(null);
            await PopupNavigation.Instance.PopAsync();
        }
        public async Task Init()
        {
            if (!Auth.IsAuthenticated())
            {
                NotificationService.Instance.Error(AppResources.UnauthenticatedAccessMessage);
                return;
            }
            _apiService = new APIService();

            _apiService.ChangeRoute(Routes.DoktoriRoute);
            var result = await _apiService.Get <DoktorDtoEL>(new DoktorResourceParameters { EagerLoaded = true });

            if (result.Succeeded)
            {
                Doktori = result.HasData ? result.Data : new List <DoktorDtoEL>();
            }
            else
            {
                NotificationService.Instance.Error(AppResources.UnableToLoadDataError);
            }
        }
        private async Task Save()
        {
            IsBusy = true;
            if (!IsValidModel)
            {
                return;
            }

            MainBodyVisible = false;

            _apiService.ChangeRoute(Routes.ZahteviZaPregledRoute);
            var upsertDto = new ZahtevZaPregledUpsertDto
            {
                DoktorId = PickedDoktor.Id,
                Napomena = Napomena
            };

            var result = await _apiService.Post <ZahtevZaPregledDtoLL>(upsertDto);

            await Task.Delay(3000);

            IsBusy = false;

            if (result.Succeeded)
            {
                NotificationService.Instance.Success(AppResources.SuccessfullyCreatedZahtevZaPregledMessage);
                await Task.Delay(200);

                await Application.Current.MainPage.PopToRootCurrentTabAsNavigationPage();
            }
            else
            {
                MainBodyVisible = true;
                NotificationService.Instance.Error(result.StatusCode == HttpStatusCode.BadRequest
                    ? result.Message
                    : string.Empty);
            }
        }