Skip to content
This repository was archived by the owner on Jan 21, 2022. It is now read-only.

Commit c874763

Browse files
committed
profile view fix, profile model improvements
1 parent ada5c1c commit c874763

4 files changed

Lines changed: 109 additions & 52 deletions

File tree

Model/Profile.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ namespace Model
77
public class Profile
88
{
99

10-
private Student Student { get; set; }
1110
public QAData QAData { get; set; }
1211
public MoralsData MoralsData { get; set; }
1312
public InterestsData InterestsData { get; set; }
@@ -18,15 +17,13 @@ public class Profile
1817

1918
public Profile(Student student)
2019
{
21-
Student = student;
2220
QAData = new QAData(student);
2321
MoralsData = new MoralsData(student);
2422
InterestsData = new InterestsData(student);
2523
Media = new Media(student);
2624
MatchList = new MatchList(student);
2725
BlockList = new BlockList(student);
28-
Description = ""; //get description from db
29-
26+
Description = "";
3027
}
3128

3229
}

Model/Student.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,36 @@ namespace Model
66
{
77

88
public enum Relationships { Friends, Business, Love, Study };
9-
internal enum DataKeys { Education, Address, DateOfBirth, School, Relationships}
9+
internal enum DataKeys { Education, City, DateOfBirth, School, Relationships}
1010
public class Student
1111
{
1212

1313
//public Account Account { get; set; }
1414
public int ID { get; set; }
1515
public string Email { get; set; }
16-
public string Eduction { get; set; }
17-
public string Address { get; set; }
16+
public string City { get; set; }
1817
public DateTime DateOfBirth { get; set; }
18+
19+
public string Age { get; set; }
1920
public School School { get; set; }
2021
public HashSet<Relationships> Relationships { get; set; }
2122
public Profile Profile { get; set; }
22-
2323
public string Name { get; set; }
2424

2525
public Student(string email)
2626
{
2727
//Account = account;
2828
Email = email;
29-
Eduction = (string)LoadObject(DataKeys.Education);
30-
Address = (string)LoadObject(DataKeys.Address);
29+
City = (string)LoadObject(DataKeys.City);
3130
DateOfBirth = (DateTime)LoadObject(DataKeys.DateOfBirth);
31+
Age = CalculateAge(DateOfBirth).ToString() + " Jaar";
3232
School = (School)LoadObject(DataKeys.School);
3333
Relationships = (HashSet<Relationships>)LoadObject(DataKeys.Relationships);
3434
Profile = new Profile(this);
3535
}
3636

3737
public Student()
3838
{
39-
4039
}
4140

4241
private object LoadObject(DataKeys data)
@@ -45,9 +44,7 @@ private object LoadObject(DataKeys data)
4544
//this method will connect to the database and load the correct data for the object
4645
switch (data)
4746
{
48-
case DataKeys.Education:
49-
break;
50-
case DataKeys.Address:
47+
case DataKeys.City:
5148
break;
5249
case DataKeys.DateOfBirth:
5350
break;
@@ -62,6 +59,16 @@ private object LoadObject(DataKeys data)
6259
return null;
6360
}
6461

62+
private static int CalculateAge(DateTime birthDay)
63+
{
64+
int years = DateTime.Now.Year - birthDay.Year;
65+
if ((birthDay.Month > DateTime.Now.Month) || (birthDay.Month == DateTime.Now.Month && birthDay.Day > DateTime.Now.Day))
66+
{
67+
years--;
68+
}
69+
70+
return years;
71+
}
6572

6673
}
6774
}

View/ProfilePage.xaml

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<Page.Resources>
1313
<VM:ProfilePageViewModel x:Key="vm"/>
1414
</Page.Resources>
15+
16+
<ScrollViewer VerticalScrollBarVisibility="Auto">
1517

1618
<Grid x:Name="AllGrids" Background="White" DataContext="{StaticResource vm}">
1719
<Grid.RowDefinitions>
@@ -22,17 +24,17 @@
2224
<RowDefinition Height="10*"/>
2325
<RowDefinition Height="10*"/>
2426
<RowDefinition Height="20*"/>
25-
<RowDefinition Height="5*"/>
27+
<RowDefinition Height="5*" MinHeight="50px"/>
2628
</Grid.RowDefinitions>
2729
<Grid.ColumnDefinitions>
28-
<ColumnDefinition Width="5*"/>
29-
<ColumnDefinition Width="5*"/>
30+
<ColumnDefinition Width="1*"/>
31+
<ColumnDefinition Width="9*"/>
3032
<ColumnDefinition Width="80*"/>
31-
<ColumnDefinition Width="5*"/>
32-
<ColumnDefinition Width="5*"/>
33+
<ColumnDefinition Width="9*"/>
34+
<ColumnDefinition Width="1*"/>
3335
</Grid.ColumnDefinitions>
34-
<Canvas x:Name="PhotoCarousel" Grid.Column="1" Grid.Row ="1" Grid.ColumnSpan="3" Grid.RowSpan="1" Background="#23000000"/>
35-
<Grid x:Name="MainInfoGrid" Grid.Column="2" Grid.Row="2" Background="#220046FF">
36+
<Canvas x:Name="PhotoCarousel" Grid.Column="1" Grid.Row ="1" Grid.ColumnSpan="3" Grid.RowSpan="1" Background="#23000000" MinHeight="450px"/>
37+
<Grid x:Name="MainInfoGrid" Grid.Column="2" Grid.Row="2" Background="#220046FF" MinHeight="150px">
3638
<Grid.ColumnDefinitions>
3739
<ColumnDefinition Width="25*"/>
3840
<ColumnDefinition Width="25*"/>
@@ -43,20 +45,20 @@
4345
<RowDefinition Height="60*"/>
4446
<RowDefinition Height="40*"/>
4547
</Grid.RowDefinitions>
46-
<Label x:Name="NameLabel" HorizontalAlignment="Center" Content="{Binding Name}" Grid.ColumnSpan="4" Grid.RowSpan="1" FontSize="48"/>
47-
<Label x:Name="AgeLabel" Content="24 jaar" HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Stretch" FontSize="20"/>
48-
<Label x:Name="LocationLabel" Content="Zwolle" Grid.Column="1" HorizontalAlignment="Center" Grid.Row="1" FontSize="20" VerticalAlignment="Stretch"/>
49-
<Label x:Name="SchoolNameLabel" Content="Windesheim" Grid.Column="2" HorizontalAlignment="Center" Grid.Row="1" FontSize="20" VerticalAlignment="Stretch"/>
50-
<Label x:Name="EducationLabel" Content="HBO-ICT" Grid.Column="3" HorizontalAlignment="Center" Grid.Row="1" FontSize="20" VerticalAlignment="Stretch"/>
48+
<Label x:Name="NameLabel" HorizontalAlignment="Center" Content="{Binding Name}" Grid.ColumnSpan="4" Grid.RowSpan="1" FontSize="32"/>
49+
<Label x:Name="AgeLabel" Content="{Binding Age}" HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Stretch" FontSize="16"/>
50+
<Label x:Name="LocationLabel" Content="{Binding City}" Grid.Column="1" HorizontalAlignment="Center" Grid.Row="1" FontSize="16" VerticalAlignment="Stretch"/>
51+
<Label x:Name="SchoolNameLabel" Content="{Binding School}" Grid.Column="2" HorizontalAlignment="Center" Grid.Row="1" FontSize="16" VerticalAlignment="Stretch"/>
52+
<Label x:Name="EducationLabel" Content="{Binding Study}" Grid.Column="3" HorizontalAlignment="Center" Grid.Row="1" FontSize="16" VerticalAlignment="Stretch"/>
5153
</Grid>
52-
<Grid x:Name="InterestsGrid" Grid.Column="2" Grid.Row="3" Background="#220046FF"/>
53-
<Grid x:Name="InformationTextGrid" Grid.Column="2" Grid.Row="4" Background="#220046FF">
54-
<TextBlock x:Name="DescriptionTextBox" TextWrapping="WrapWithOverflow" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,10,10" FontSize="18" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."/>
54+
<Grid x:Name="InterestsGrid" Grid.Column="2" Grid.Row="3" Background="#220046FF" MinHeight="100px"/>
55+
<Grid x:Name="InformationTextGrid" Grid.Column="2" Grid.Row="4" Background="#220046FF" MinHeight="250px">
56+
<TextBlock x:Name="DescriptionTextBox" TextWrapping="WrapWithOverflow" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,10,10" FontSize="18" Text="{Binding Description}"/>
5557
</Grid>
5658
<Grid/>
57-
<Grid x:Name="QAGrid" Grid.Column="2" Grid.Row="5" Background="#220046FF"/>
59+
<Grid x:Name="QAGrid" Grid.Column="2" Grid.Row="5" Background="#220046FF" MinHeight="250px"/>
5860
<Grid/>
59-
<Grid x:Name="PriorityGrid" Grid.Column="2" Grid.Row="6" Background="#220046FF">
61+
<Grid x:Name="PriorityGrid" Grid.Column="2" Grid.Row="6" Background="#220046FF" MinHeight="210px">
6062
<Grid.ColumnDefinitions>
6163
<ColumnDefinition Width="2*"/>
6264
<ColumnDefinition Width="8*"/>
@@ -70,27 +72,28 @@
7072
<RowDefinition Height="1*"/>
7173
<RowDefinition Height="1*"/>
7274
</Grid.RowDefinitions>
73-
<Label x:Name="PriorityLabelIntelligence" Grid.Column="0" Grid.Row="0" Content="Intelligentie" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="18" Margin="10,0,0,0"/>
75+
<Label x:Name="PriorityLabelIntelligence" Grid.Column="0" Grid.Row="0" Content="Intelligentie" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="16" Margin="10,0,0,0"/>
7476
<ProgressBar x:Name="IntelligenceProgressBar" Grid.Column="1" Grid.Row="0" Background="#220046FF" Margin="10,10,10,10" Value="50" Foreground="#FF0615B0" MaxHeight="12" MinHeight="12"/>
7577

76-
<Label x:Name="FysicsLabel" Grid.Column="0" Grid.Row="1" Content="Fysieke Activiteiten" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="18" Margin="10,0,0,0"/>
78+
<Label x:Name="FysicsLabel" Grid.Column="0" Grid.Row="1" Content="Fysieke Activiteiten" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="16" Margin="10,0,0,0"/>
7779
<ProgressBar x:Name="FysicsProgressBar" Grid.Column="1" Grid.Row="1" Background="#220046FF" Margin="10,10,10,10" Value="20" Foreground="#FF0615B0" MaxHeight="12" MinHeight="12"/>
7880

79-
<Label x:Name="ClubbingLabel" Grid.Column="0" Grid.Row="2" Content="Uitgaansleven" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="18" Margin="10,0,0,0"/>
81+
<Label x:Name="ClubbingLabel" Grid.Column="0" Grid.Row="2" Content="Uitgaansleven" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="16" Margin="10,0,0,0"/>
8082
<ProgressBar x:Name="ClubbingProgressBar" Grid.Column="1" Grid.Row="2" Background="#220046FF" Margin="10,10,10,10" Value="90" Foreground="#FF0615B0" MaxHeight="12" MinHeight="12"/>
8183

82-
<Label x:Name="NatureLabel" Grid.Column="0" Grid.Row="3" Content="Natuur" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="18" Margin="10,0,0,0"/>
84+
<Label x:Name="NatureLabel" Grid.Column="0" Grid.Row="3" Content="Natuur" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="16" Margin="10,0,0,0"/>
8385
<ProgressBar x:Name="NatureProgressBar" Grid.Column="1" Grid.Row="3" Background="#220046FF" Margin="10,10,10,10" Value="3" Foreground="#FF0615B0" MaxHeight="12" MinHeight="12"/>
8486

85-
<Label x:Name="PoliticsLabel" Grid.Column="0" Grid.Row="4" Content="Politiek" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="18" Margin="10,0,0,0"/>
87+
<Label x:Name="PoliticsLabel" Grid.Column="0" Grid.Row="4" Content="Politiek" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="16" Margin="10,0,0,0"/>
8688
<ProgressBar x:Name="PoliticsProgressBar" Grid.Column="1" Grid.Row="4" Background="#220046FF" Margin="10,10,10,10" Value="65" Foreground="#FF0615B0" MaxHeight="12" MinHeight="12"/>
8789

88-
<Label x:Name="WorkLabel" Grid.Column="0" Grid.Row="5" Content="Werk prestaties" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="18" Margin="10,0,0,0"/>
90+
<Label x:Name="WorkLabel" Grid.Column="0" Grid.Row="5" Content="Werk prestaties" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="16" Margin="10,0,0,0"/>
8991
<ProgressBar x:Name="WorkProgressBar" Grid.Column="1" Grid.Row="5" Background="#220046FF" Margin="10,10,10,10" Value="45" Foreground="#FF0615B0" MaxHeight="12" MinHeight="12"/>
9092

91-
<Label x:Name="ClimateLabel" Grid.Column="0" Grid.Row="6" Content="Klimaat" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="18" Margin="10,0,0,0"/>
93+
<Label x:Name="ClimateLabel" Grid.Column="0" Grid.Row="6" Content="Klimaat" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="16" Margin="10,0,0,0"/>
9294
<ProgressBar x:Name="ClimateProgressBar" Grid.Column="1" Grid.Row="6" Background="#220046FF" Margin="10,10,10,10" Value="10" Foreground="#FF0615B0" MaxHeight="12" MinHeight="12"/>
9395
</Grid>
9496

9597
</Grid>
98+
</ScrollViewer>
9699
</Page>

ViewModel/ProfilePageViewModel.cs

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,93 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.ComponentModel;
4-
using System.Text;
53
using Model;
64
namespace ViewModel
75
{
86
public class ProfilePageViewModel : INotifyPropertyChanged
97
{
10-
public string Name {
11-
get
12-
{
13-
14-
return _student.Name;
15-
}
8+
public string Name
9+
{
10+
get => _student.Name;
1611
set
1712
{
1813
_student.Name = value;
1914
OnPropertyChanged("Name");
2015
}
2116
}
2217

23-
private Student _student;
18+
public string School
19+
{
20+
get => _student.School.Name;
21+
set
22+
{
23+
_student.School.Name = value;
24+
OnPropertyChanged("School");
25+
}
26+
}
2427

28+
public string City
29+
{
30+
get => _student.City;
31+
set
32+
{
33+
_student.City = value;
34+
OnPropertyChanged("Address");
35+
}
36+
}
2537

26-
public event PropertyChangedEventHandler PropertyChanged;
38+
public string Study
39+
{
40+
get => _student.School.Study;
41+
set
42+
{
43+
_student.School.Study = value;
44+
OnPropertyChanged("Study");
45+
}
46+
}
2747

28-
public ProfilePageViewModel()
48+
public string Age
2949
{
50+
get => _student.Age;
51+
set
52+
{
53+
_student.Age = value;
54+
OnPropertyChanged("Age");
55+
}
56+
}
57+
58+
public string Description
59+
{
60+
get => _student.Profile.Description;
61+
set
62+
{
63+
_student.Profile.Description = value;
64+
OnPropertyChanged("Description");
65+
}
66+
}
3067

68+
private Student _student;
3169

32-
70+
public event PropertyChangedEventHandler PropertyChanged;
3371

34-
_student = new Student();
35-
_student.Name = "";
72+
public ProfilePageViewModel()
73+
{
74+
_student = new Student
75+
{
76+
Name = "Henk Pitjes",
77+
School = new School("Windesheim", "Zwolle", "HBO-ICT"),
78+
Age = "25 jaar",
79+
City = "Leeuwarden",
80+
Email = "Foo@bar.com",
81+
ID = 1,
82+
Profile = new Profile(_student)
83+
};
84+
_student.Profile.Description = "Laat me raden... Je hebt al de nodige bagage. Dit hele online daten is niet wat je wilt, omdat je liever iemand in de supermarkt ontmoet. Dat begrijp ik. En eerlijk gezegd? Ik ook. Hoi, ik ben Jack. Ik lijk niet op Ryan Gosling. Ik heb geen vrijwilligerswerk gedaan in Madagaskar. En heel eerlijk? Grote vissen vind té eng om mee te poseren. Wat ik wil zeggen is… dat ik niet perfect ben. En dat verwacht ik ook niet van jou. Wat ik wel ben? Doordeweeks ga ik door het leven als datingconsulent. Het geeft me een fijn gevoel om te zien hoe eenzame mensen veranderen in stralende levensgenieters. Mensen vragen me weleens wat ik doe.En dan zeg ik: “Ik voorspel de toekomst“. Als datingconsulent heb ik geen glazen bol nodig. Ik leg foto’s van mensen naast elkaar op tafel, geen tarot kaarten.Maar wat ik van maandag tot vrijdag vooral doe, is uitkijken naar zaterdag en zondag. Want dan gaan de serieuze kleren uit en spring ik in het diepe. Letterlijk, want ik zwem graag. Het liefst met een duikfles op mijn rug om de verloren schatten van de Rijn te ontdekken. Tot nu toe zijn het alleen halve fietswrakken geweest en verroeste auto-onderdelen, maar hey… ik geef de moed niet op. Een andere schat waar ik naar op zoek ben is intelligent, creatief en een familiemens. Klinkt dat als jou? Ik geef eerlijk toe dat ik soms met een beetje geluk de toekomst van anderen kan voorspellen, maar ik ben geen helderziende.Dus, als je denkt dat wij een klik kunnen hebben… Stuur me een bericht!"; //get description from db
3685
}
3786

3887
private void OnPropertyChanged(string property = null)
3988
{
4089
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
4190
}
91+
4292
}
4393
}

0 commit comments

Comments
 (0)