Example #1
0
        private void UpdateBtn_Clicked(object sender, EventArgs e)
        {
            if (SmartHospitalAPI.GetUser(User.JwtToken, out JObject userObj) == System.Net.HttpStatusCode.OK)
            {
                User.Id    = (int)userObj["id"];
                User.Email = userObj["email"].ToString();
                User.FIO   = userObj["fio"].ToString();
            }
            if (SmartHospitalAPI.GetInfo(User.JwtToken, out JObject userInfo) == System.Net.HttpStatusCode.OK)
            {
                User.CardId = (int)userInfo["cardId"];
            }

            if (SmartHospitalAPI.GetCard(User.JwtToken, User.CardId, out JObject patientCard) == System.Net.HttpStatusCode.OK)
            {
                UserPage.list.Clear();
                var list = patientCard["History"].ToList();

                foreach (var note in list)
                {
                    Card userNote = JsonConvert.DeserializeObject <Card>(note.ToString());
                    SmartHospitalAPI.GetDoctor(User.JwtToken, userNote.DoctorId, out Doctor doctor);

                    if (doctor != null)
                    {
                        userNote.DoctorFIO = doctor.Fio;
                    }

                    UserPage.list.Add(new Label()
                    {
                        Text = userNote.ToString()
                    });
                }
            }
        }
Example #2
0
        private async void RegistrationBtn_Clicked(object sender, EventArgs e)
        {
            string errorMessage = string.Empty;

            if (string.IsNullOrWhiteSpace(FioEntry.Text))
            {
                errorMessage += "Некорректное ФИО\n";
            }

            if (string.IsNullOrWhiteSpace(EmailEntry.Text) || !IsEmailFormat(EmailEntry?.Text))
            {
                errorMessage += "Некорректный Email\n";
            }

            if (string.IsNullOrWhiteSpace(PasswordEntry.Text) || PasswordEntry.Text.Length < 4)
            {
                errorMessage += "Некорректный пароль";
            }

            if (errorMessage != string.Empty)
            {
                await DisplayAlert("Ошибка", errorMessage, "ОK");

                return;
            }

            if (SmartHospitalAPI.Registration(EmailEntry.Text, PasswordEntry.Text, FioEntry.Text, false, out string jwtToken)
                == System.Net.HttpStatusCode.OK)
            {
                User.JwtToken = jwtToken;
                await Navigation.PushAsync(new UserPage());
            }
            else
            {
                await DisplayAlert("Ошибка", "Неудачная попытка регистрации!", "ОK");
            }


            bool IsEmailFormat(string email)
            {
                if (email == null)
                {
                    return(false);
                }

                Regex reg = new Regex(@"^([a-z0-9_-]+\.)*[a-z0-9_-]+@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[a-z]{2,6}$");

                return(reg.IsMatch(email));
            }
        }
Example #3
0
        public UserPage()
        {
            InitializeComponent();
            CollView.ItemsSource = list;

            if (SmartHospitalAPI.GetUser(User.JwtToken, out JObject userObj) == System.Net.HttpStatusCode.OK)
            {
                User.Id            = (int)userObj["id"];
                User.Email         = userObj["email"].ToString();
                User.FIO           = userObj["fio"].ToString();
                UserNameLabel.Text = User.FIO;
            }
            //if (SmartHospitalAPI.GetInfo(User.JwtToken, out JObject userInfo) == System.Net.HttpStatusCode.OK)
            //{
            //    User.CardId = (int)userInfo["cardId"];
            //}

            //if (SmartHospitalAPI.GetCard(User.JwtToken, User.CardId, out JObject patientCard) == System.Net.HttpStatusCode.OK)
            //{
            //    var jonj = patientCard; //User.Cards = patientCard;
            //}
        }