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

Commit 3968d1c

Browse files
Merge pull request #12 from Standaard-boos/ProfileV2
Profile v2
2 parents d0b31e7 + 23877ca commit 3968d1c

6 files changed

Lines changed: 165 additions & 39 deletions

File tree

Model/BlockList.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,34 @@
44

55
namespace Model
66
{
7+
/*This class contains the list of all blocked students for the current user*/
78
public class BlockList
89
{
910

10-
private List<Student> BlockedStudents { get; set; }
11+
public List<Student> BlockedStudents { get; set; }
1112
private Student Student;
12-
1313
public BlockList(Student student)
1414
{
1515
Student = student;
1616
BlockedStudents = new List<Student>();
1717
//update list according to database
1818
}
1919

20+
/*Adds arg student to blocked list*/
2021
public void AddBlock(Student student)
2122
{
2223
BlockedStudents.Add(student);
2324
//database update
2425
}
2526

27+
/*removes arg student from blocked list*/
2628
public void RemoveBlock(Student student)
2729
{
2830
BlockedStudents.Remove(student);
2931
//database update
3032
}
3133

34+
/*returns if arg student is in the blocked list*/
3235
public bool IsBlocked(Student student)
3336
{
3437
return BlockedStudents.Contains(student);

Model/MatchList.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
namespace Model
66
{
7-
class MatchList
7+
public class MatchList
88
{
9-
10-
private HashSet<Match> Matches { get; set; }
9+
public HashSet<Match> Matches { get; set; }
1110
private Student Student;
1211

1312
public MatchList(Student student)

Model/Profile.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,23 @@ namespace Model
77
public class Profile
88
{
99

10-
private Student Student { get; set; }
11-
private QAData QAData { get; set; }
12-
private MoralsData MoralsData { get; set; }
13-
private InterestsData InterestsData { get; set; }
14-
private string Description { get; set; }
15-
private Media Media { get; set; }
16-
private MatchList MatchList { get; set; }
17-
private BlockList BlockList { get; set; }
10+
public QAData QAData { get; set; }
11+
public MoralsData MoralsData { get; set; }
12+
public InterestsData InterestsData { get; set; }
13+
public string Description { get; set; }
14+
public Media Media { get; set; }
15+
public MatchList MatchList { get; set; }
16+
public BlockList BlockList { get; set; }
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: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +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; }
22+
public Profile Profile { get; set; }
23+
public string Name { get; set; }
2124

2225
public Student(string email)
2326
{
2427
//Account = account;
2528
Email = email;
26-
Eduction = (string)LoadObject(DataKeys.Education);
27-
Address = (string)LoadObject(DataKeys.Address);
29+
City = (string)LoadObject(DataKeys.City);
2830
DateOfBirth = (DateTime)LoadObject(DataKeys.DateOfBirth);
31+
Age = CalculateAge(DateOfBirth).ToString() + " Jaar";
2932
School = (School)LoadObject(DataKeys.School);
3033
Relationships = (HashSet<Relationships>)LoadObject(DataKeys.Relationships);
34+
Profile = new Profile(this);
35+
}
36+
37+
public Student()
38+
{
3139
}
3240

3341
private object LoadObject(DataKeys data)
@@ -36,9 +44,7 @@ private object LoadObject(DataKeys data)
3644
//this method will connect to the database and load the correct data for the object
3745
switch (data)
3846
{
39-
case DataKeys.Education:
40-
break;
41-
case DataKeys.Address:
47+
case DataKeys.City:
4248
break;
4349
case DataKeys.DateOfBirth:
4450
break;
@@ -53,6 +59,16 @@ private object LoadObject(DataKeys data)
5359
return null;
5460
}
5561

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+
}
5672

5773
}
5874
}

View/ProfilePage.xaml

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:View"
7+
xmlns:VM="clr-namespace:ViewModel;assembly=ViewModel"
78
mc:Ignorable="d"
89
d:DesignHeight="1920" d:DesignWidth="1080"
910
Title="Profile">
1011

11-
<Grid x:Name="AllGrids">
12+
13+
<Page.Resources>
14+
<VM:ProfilePageViewModel x:Key="vm"/>
15+
</Page.Resources>
16+
17+
<ScrollViewer VerticalScrollBarVisibility="Auto">
18+
19+
<Grid x:Name="AllGrids" Background="White" DataContext="{StaticResource vm}">
20+
1221
<Grid.RowDefinitions>
1322
<RowDefinition Height="5*"/>
1423
<RowDefinition Height="35*"/>
@@ -17,17 +26,19 @@
1726
<RowDefinition Height="10*"/>
1827
<RowDefinition Height="10*"/>
1928
<RowDefinition Height="20*"/>
20-
<RowDefinition Height="5*"/>
29+
<RowDefinition Height="5*" MinHeight="50px"/>
2130
</Grid.RowDefinitions>
2231
<Grid.ColumnDefinitions>
23-
<ColumnDefinition Width="5*"/>
24-
<ColumnDefinition Width="5*"/>
32+
<ColumnDefinition Width="1*"/>
33+
<ColumnDefinition Width="9*"/>
2534
<ColumnDefinition Width="80*"/>
26-
<ColumnDefinition Width="5*"/>
27-
<ColumnDefinition Width="5*"/>
35+
<ColumnDefinition Width="9*"/>
36+
<ColumnDefinition Width="1*"/>
2837
</Grid.ColumnDefinitions>
38+
2939
<Canvas x:Name="PhotoCarousel" Grid.Column="1" Grid.Row ="1" Grid.ColumnSpan="3" Grid.RowSpan="1" Background="#23000000"/>
3040
<Grid x:Name="MainInfoGrid" Grid.Column="2" Grid.Row="2" Background="{StaticResource BackgroundSecundary}">
41+
3142
<Grid.ColumnDefinitions>
3243
<ColumnDefinition Width="25*"/>
3344
<ColumnDefinition Width="25*"/>
@@ -38,20 +49,24 @@
3849
<RowDefinition Height="60*"/>
3950
<RowDefinition Height="40*"/>
4051
</Grid.RowDefinitions>
41-
<Label x:Name="NameLabel" HorizontalAlignment="Center" Content="PETER JANSEN" Grid.ColumnSpan="4" Grid.RowSpan="1" FontSize="48"/>
42-
<Label x:Name="AgeLabel" Content="24 jaar" HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Stretch"/>
43-
<Label x:Name="LocationLabel" Content="Zwolle" Grid.Column="1" HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Stretch"/>
44-
<Label x:Name="SchoolNameLabel" Content="Windesheim" Grid.Column="2" HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Stretch"/>
45-
<Label x:Name="EducationLabel" Content="HBO-ICT" Grid.Column="3" HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Stretch"/>
52+
53+
<Label x:Name="NameLabel" HorizontalAlignment="Center" Content="{Binding Name}" Grid.ColumnSpan="4" Grid.RowSpan="1" FontSize="32"/>
54+
<Label x:Name="AgeLabel" Content="{Binding Age}" HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Stretch" FontSize="16"/>
55+
<Label x:Name="LocationLabel" Content="{Binding City}" Grid.Column="1" HorizontalAlignment="Center" Grid.Row="1" FontSize="16" VerticalAlignment="Stretch"/>
56+
<Label x:Name="SchoolNameLabel" Content="{Binding School}" Grid.Column="2" HorizontalAlignment="Center" Grid.Row="1" FontSize="16" VerticalAlignment="Stretch"/>
57+
<Label x:Name="EducationLabel" Content="{Binding Study}" Grid.Column="3" HorizontalAlignment="Center" Grid.Row="1" FontSize="16" VerticalAlignment="Stretch"/>
4658
</Grid>
47-
<Grid x:Name="InterestsGrid" Grid.Column="2" Grid.Row="3" Background="{StaticResource BackgroundSecundary}"/>
48-
<Grid x:Name="InformationTextGrid" Grid.Column="2" Grid.Row="4" Background="{StaticResource BackgroundSecundary}">
49-
<TextBlock x:Name="DescriptionTextBox" TextWrapping="WrapWithOverflow" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,10,10" 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."/>
59+
<Grid x:Name="InterestsGrid" Grid.Column="2" Grid.Row="3" Background="{StaticResource BackgroundSecundary}" MinHeight="100px"/>
60+
<Grid x:Name="InformationTextGrid" Grid.Column="2" Grid.Row="4" Background="{StaticResource BackgroundSecundary}" MinHeight="250px">
61+
<TextBlock x:Name="DescriptionTextBox" TextWrapping="WrapWithOverflow" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,10,10" FontSize="18" Text="{Binding Description}"/>
5062
</Grid>
51-
<Grid/>
63+
<Grid/>
64+
5265
<Grid x:Name="QAGrid" Grid.Column="2" Grid.Row="5" Background="{StaticResource BackgroundSecundary}"/>
5366
<Grid/>
5467
<Grid x:Name="PriorityGrid" Grid.Column="2" Grid.Row="6" Background="{StaticResource BackgroundSecundary}">
68+
69+
5570
<Grid.ColumnDefinitions>
5671
<ColumnDefinition Width="2*"/>
5772
<ColumnDefinition Width="8*"/>
@@ -65,6 +80,7 @@
6580
<RowDefinition Height="1*"/>
6681
<RowDefinition Height="1*"/>
6782
</Grid.RowDefinitions>
83+
6884
<Label x:Name="PriorityLabelIntelligence" Grid.Column="0" Grid.Row="0" Content="Intelligentie" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="10,0,0,0"/>
6985
<ProgressBar x:Name="IntelligenceProgressBar" Grid.Column="1" Grid.Row="0" Background="{StaticResource BackgroundSecundary}" Margin="10,10,10,10" Value="50" Foreground="{StaticResource BackgroundQuaternary}" MaxHeight="12" MinHeight="12"/>
7086

@@ -85,7 +101,9 @@
85101

86102
<Label x:Name="ClimateLabel" Grid.Column="0" Grid.Row="6" Content="Klimaat" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="10,0,0,0"/>
87103
<ProgressBar x:Name="ClimateProgressBar" Grid.Column="1" Grid.Row="6" Background="{StaticResource BackgroundSecundary}" Margin="10,10,10,10" Value="10" Foreground="{StaticResource BackgroundQuaternary}" MaxHeight="12" MinHeight="12"/>
104+
88105
</Grid>
89106

90107
</Grid>
108+
</ScrollViewer>
91109
</Page>

ViewModel/ProfilePageViewModel.cs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using System;
2+
using System.ComponentModel;
3+
using Model;
4+
namespace ViewModel
5+
{
6+
public class ProfilePageViewModel : INotifyPropertyChanged
7+
{
8+
public string Name
9+
{
10+
get => _student.Name;
11+
set
12+
{
13+
_student.Name = value;
14+
OnPropertyChanged("Name");
15+
}
16+
}
17+
18+
public string School
19+
{
20+
get => _student.School.Name;
21+
set
22+
{
23+
_student.School.Name = value;
24+
OnPropertyChanged("School");
25+
}
26+
}
27+
28+
public string City
29+
{
30+
get => _student.City;
31+
set
32+
{
33+
_student.City = value;
34+
OnPropertyChanged("Address");
35+
}
36+
}
37+
38+
public string Study
39+
{
40+
get => _student.School.Study;
41+
set
42+
{
43+
_student.School.Study = value;
44+
OnPropertyChanged("Study");
45+
}
46+
}
47+
48+
public string Age
49+
{
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+
}
67+
68+
private Student _student;
69+
70+
public event PropertyChangedEventHandler PropertyChanged;
71+
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
85+
}
86+
87+
private void OnPropertyChanged(string property = null)
88+
{
89+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
90+
}
91+
92+
}
93+
}

0 commit comments

Comments
 (0)