Example #1
0
        private async Task setIndividualValue(GetIndividualResponse r, getUserResult user)
        {
            //userName.Text = DatabaseHelper.CurrentUser;
            //password.Password = user.password;
            FirstNameTbx.Text       = r.FirstName;
            MidNameTbx.Text         = r.MiddleName;
            LastnameTbx.Text        = r.LastName;
            BirthdayPicker.Date     = r.DOB.Date;
            GenderCbx.SelectedIndex = r.Gender ? 0 : 1;

            StorageFile file = await StorageFile.GetFileFromPathAsync(user.profilePicture);

            BitmapImage bmp = new BitmapImage();
            await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

            indAvatar.Source = bmp;
            cover            = user.coverPicture;
            profile          = user.profilePicture;
            file             = await StorageFile.GetFileFromPathAsync(user.coverPicture);

            bmp = new BitmapImage();
            await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

            indCover.Source = bmp;
        }
Example #2
0
        private async Task resetValue()
        {
            if (userTypeValue == 2)
            {
                IndividualPanel.Visibility = Visibility.Collapsed;
            }
            else if (userTypeValue == 1)
            {
                OrganizationPanel.Visibility = Visibility.Collapsed;
                GetIndividualRequest  a = new GetIndividualRequest(DatabaseHelper.CurrentUser);
                GetIndividualResponse r = await DatabaseHelper.Client.GetIndividualAsync(a);

                getUserResult user = (await DatabaseHelper.Client.GetUserAsync(DatabaseHelper.CurrentUser)).First();
                await setIndividualValue(r, user);
            }
        }
Example #3
0
        private void AddBasicInfoCard(string username, GetIndividualResponse response)
        {
            DisplayCard card    = new DisplayCard();
            StackPanel  content = new StackPanel();

            card.CardTitle = "Basic information";
            content.Margin = new Thickness(16, 0, 16, 16);

            TextBlock info = new TextBlock();

            info.Text = "Firstname:\t" + response.FirstName + "\n" +
                        ((response.MiddleName != "") ? "Middlename:\t" + response.MiddleName + "\n" : "") +
                        "Lastname:\t" + response.LastName + "\n\n";
            info.Text += "Birthday:\t\t" + response.DOB.ToString("d") + "\n";
            info.Text += "Gender:\t\t" + (response.Gender ? "Male" : "Female");

            content.Children.Add(info);
            card.PlaceHolder = content;
            AboutPanel.Children.Add(card);
        }
Example #4
0
        private async Task setIndividualValue(GetIndividualResponse r, getUserResult user)
        {
            //userName.Text = DatabaseHelper.CurrentUser;
            //password.Password = user.password;
            FirstNameTbx.Text = r.FirstName;
            MidNameTbx.Text = r.MiddleName;
            LastnameTbx.Text = r.LastName;
            BirthdayPicker.Date = r.DOB.Date;
            GenderCbx.SelectedIndex = r.Gender ? 0 : 1;

            StorageFile file = await StorageFile.GetFileFromPathAsync(user.profilePicture);
            BitmapImage bmp = new BitmapImage();
            await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));
            indAvatar.Source = bmp;
            cover = user.coverPicture;
            profile = user.profilePicture;
            file = await StorageFile.GetFileFromPathAsync(user.coverPicture);
            bmp = new BitmapImage();
            await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));
            indCover.Source = bmp;
        }
Example #5
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            userName = e.Parameter.ToString();
            if (userName == DatabaseHelper.CurrentUser)
            {
                // Remove follow button
                FollowBtn.Visibility   = Visibility.Collapsed;
                UnfollowBtn.Visibility = Visibility.Collapsed;
            }
            else
            {
                // Remove setting button
                SettingBtn.Visibility = Visibility.Collapsed;
                if (await DatabaseHelper.Client.IsFollowingAsync(DatabaseHelper.CurrentUser, userName))
                {
                    FollowBtn.Visibility = Visibility.Collapsed;
                }
                else
                {
                    UnfollowBtn.Visibility = Visibility.Collapsed;
                }
            }

            userType = await DatabaseHelper.Client.UserTypeAsync(userName);

            //Get User following and follwers
            await followingListViewModel.getFollowingList(userName);

            await followerListViewModel.getFollowerList(userName);

            if (userType == 1)
            {
                GetIndividualRequest  a = new GetIndividualRequest(userName);
                GetIndividualResponse r = await DatabaseHelper.Client.GetIndividualAsync(a);

                Firstname.Text      = r.FirstName;
                AdditionalInfo.Text = userName;
                AddBasicInfoCard(userName, r);

                // Set profile picture
                StorageFile file;
                BitmapImage bmp;
                if (r.ProfilePic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.ProfilePic);

                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

                    AvatarBrush.ImageSource = bmp;
                }

                // Set cover picture
                if (r.CoverPic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.CoverPic);

                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

                    CoverImage.Source = bmp;
                }
            }
            else if (userType == 2)
            {
                GetOrganizationRequest  a = new GetOrganizationRequest(userName);
                GetOrganizationResponse r = await DatabaseHelper.Client.GetOrganizationAsync(a);

                Firstname.Text      = r.Name;
                AdditionalInfo.Text = r.Type;
                AddBasicInfoCard(userName, r);

                // Set profile picture
                StorageFile file;
                BitmapImage bmp;
                if (r.ProfilePic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.ProfilePic);

                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

                    AvatarBrush.ImageSource = bmp;
                }

                // Set cover picture
                if (r.CoverPic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.CoverPic);

                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

                    CoverImage.Source = bmp;
                }
            }
        }
Example #6
0
        public async Task <GetIndividualResponse> GetIndividual(GetIndividualRequest request)
        {
            var response = new GetIndividualResponse {
                Individual = null
            };

            using (var connection = new SqlConnection(_connectionString))
            {
                using (var command = new SqlCommand())
                {
                    command.CommandText = "dbo.spGetIndividual";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Connection  = connection;
                    command.Parameters.Add(new SqlParameter("@Id", request.Id.Value));
                    await connection.OpenAsync();

                    var reader = await command.ExecuteReaderAsync();

                    if (!reader.HasRows)
                    {
                        return(response);
                    }

                    response = new GetIndividualResponse {
                        Individual = new GetIndividualItem()
                    };
                    await reader.ReadAsync();

                    response.Individual.Id =
                        reader["Id"] != null?Convert.ToInt32(reader["Id"].ToString()) : default(int);

                    response.Individual.FirstName =
                        reader["FirstName"] != null ? reader["FirstName"].ToString() : string.Empty;
                    response.Individual.LastName =
                        reader["LastName"] != null ? reader["LastName"].ToString() : string.Empty;
                    response.Individual.PersonalId =
                        reader["PersonalId"] != null ? reader["PersonalId"].ToString(): string.Empty;
                    response.Individual.Gender = reader["Gender"] != null
                            ? Convert.ToInt32(reader["Gender"].ToString())
                            : (int?)null;

                    response.Individual.BirthDate = reader["BirthDate"] != null
                            ? Convert.ToDateTime(reader["BirthDate"].ToString())
                            : (DateTime?)null;

                    response.Individual.ImagePath = reader["ImagePath"] != null
                            ? reader["ImagePath"].ToString()
                            : string.Empty;
                    response.Individual.CityId = reader["CityId"] != null
                            ? Convert.ToInt32(reader["CityId"].ToString())
                            : (int?)null;

                    response.Individual.City = reader["City"] != null ? reader["City"].ToString() : string.Empty;


                    await reader.NextResultAsync();

                    if (reader.HasRows)
                    {
                        response.Individual.ConnectedIndividuals = new List <ConnectedIndividualItem>();
                        while (await reader.ReadAsync())
                        {
                            var individual = new ConnectedIndividualItem
                            {
                                Id = reader["Id"] != null?Convert.ToInt32(reader["Id"]) : default(int),
                                         FirstName =
                                             reader["FirstName"] != null ? reader["FirstName"].ToString() : string.Empty,
                                         LastName =
                                             reader["LastName"] != null ? reader["LastName"].ToString() : string.Empty,
                                         PersonalId =
                                             reader["PersonalId"] != null ? reader["PersonalId"].ToString() : string.Empty,
                                         Gender = reader["Gender"] != null
                                    ? Convert.ToInt32(reader["Gender"].ToString())
                                    : (int?)null,
                                         BirthDate = reader["BirthDate"] != null
                                    ? Convert.ToDateTime(reader["BirthDate"].ToString())
                                    : (DateTime?)null,
                                         ImagePath = reader["ImagePath"] != null
                                    ? reader["ImagePath"].ToString()
                                    : string.Empty,
                                         ConnectionType = reader["ConnectionType"] != null
                                    ? Convert.ToInt32(reader["ConnectionType"].ToString())
                                    : (int?)null
                            };
                            response.Individual.ConnectedIndividuals.Add(individual);
                        }
                    }

                    await reader.NextResultAsync();

                    if (reader.HasRows)
                    {
                        response.Individual.PhoneNumbers = new List <PhoneNumberItem>();

                        while (await reader.ReadAsync())
                        {
                            var phone = new PhoneNumberItem
                            {
                                PhoneNumberId = reader["PhoneNumberId"] != null
                                    ? Convert.ToInt32(reader["PhoneNumberId"].ToString())
                                    : default(int),
                                PhoneNumber = reader["PhoneNumber"] != null
                                    ? reader["PhoneNumber"].ToString()
                                    : string.Empty,
                                PhoneNumberType = reader["PhoneNumberType"] != null
                                    ? Convert.ToInt32(reader["PhoneNumberType"].ToString())
                                    : (int?)null
                            };
                            response.Individual.PhoneNumbers.Add(phone);
                        }
                    }
                }
            }

            return(response);
        }
Example #7
0
        private void AddBasicInfoCard(string username, GetIndividualResponse response)
        {
            DisplayCard card = new DisplayCard();
            StackPanel content = new StackPanel();

            card.CardTitle = "Basic information";
            content.Margin = new Thickness(16, 0, 16, 16);

            TextBlock info = new TextBlock();
            info.Text = "Firstname:\t" + response.FirstName + "\n" +
                ((response.MiddleName != "") ? "Middlename:\t" + response.MiddleName + "\n" : "") + 
                "Lastname:\t" + response.LastName + "\n\n";
            info.Text += "Birthday:\t\t" + response.DOB.ToString("d") + "\n";
            info.Text += "Gender:\t\t" + (response.Gender ? "Male" : "Female");

            content.Children.Add(info);
            card.PlaceHolder = content;
            AboutPanel.Children.Add(card);
        }