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

Commit fe0d185

Browse files
committed
Project types finished
1 parent 125209d commit fe0d185

File tree

20 files changed

+599
-42
lines changed

20 files changed

+599
-42
lines changed
8.21 KB
Binary file not shown.

.vs/TakeMyTime.NETCore/v16/.suo

7.5 KB
Binary file not shown.

TakeMyTime.BLL/Logic/ProjectTypeLogic.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public ProjectTypeLogic(UnitOfWork uow = null)
2424

2525
public IEnumerable<ProjectType> GetProjectTypes()
2626
{
27-
return unitOfWork.ProjectTypes.GetAll();
27+
return unitOfWork.ProjectTypes.GetProjectTypesLoaded();
2828
}
2929

3030
public ProjectType GetProjectType(int id)
3131
{
32-
return unitOfWork.ProjectTypes.Get(id);
32+
return unitOfWork.ProjectTypes.GetProjectTypeByIdLoaded(id);
3333
}
3434

3535
public void AddProjectType(ProjectType.ICreateParam param)
@@ -48,7 +48,7 @@ public void UpdateProjectType(int id, ProjectType.IUpdateParam param)
4848

4949
public void DeleteProjectType(int id)
5050
{
51-
var projectType = this.unitOfWork.ProjectTypes.Get(id);
51+
var projectType = this.unitOfWork.ProjectTypes.GetProjectTypeByIdLoaded(id);
5252
if (projectType.CanDelete())
5353
{
5454
this.unitOfWork.ProjectTypes.Remove(projectType);

TakeMyTime.DAL/Interfaces/IProjectTypeRepository.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ namespace TakeMyTime.DAL.Interfaces
77
{
88
public interface IProjectTypeRepository : IRepository<ProjectType>
99
{
10+
IEnumerable<ProjectType> GetProjectTypesLoaded();
11+
ProjectType GetProjectTypeByIdLoaded(int id);
1012
}
1113
}

TakeMyTime.DAL/Repositories/ProjectTypeRepository.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Microsoft.EntityFrameworkCore;
22
using System;
33
using System.Collections.Generic;
4+
using System.Linq;
45
using System.Text;
56
using TakeMyTime.DAL.Interfaces;
67
using TakeMyTime.Models.Models;
@@ -19,5 +20,15 @@ public TakeMyTimeDbContext TakeMyTimeDbContext
1920
{
2021
get { return DbContext as TakeMyTimeDbContext; }
2122
}
23+
24+
public IEnumerable<ProjectType> GetProjectTypesLoaded()
25+
{
26+
return this.context.ProjectTypes.Include(pt => pt.Projects);
27+
}
28+
29+
public ProjectType GetProjectTypeByIdLoaded(int id)
30+
{
31+
return this.context.ProjectTypes.Include(pt => pt.Projects).SingleOrDefault(pt => pt.Id == id);
32+
}
2233
}
2334
}

TakeMyTime.Models.Tests/ProjectTypeTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ public void Update_Test()
3636
var projectType = ProjectType.Create(createParam);
3737
string changedName = "Test name changed";
3838
string changedDescription = "Test description changed";
39+
var updateParam = new ProjectTypeUpdateParam { Description = changedDescription, Name = changedName };
3940

4041
// ACT
41-
projectType.Update(changedName, changedDescription);
42+
projectType.Update(updateParam);
4243

4344
// ASSERT
4445
Assert.AreEqual(changedName, projectType.Name);

TakeMyTime.Models/Models/ProjectType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ public void RemoveProject(Project project)
6060
}
6161

6262
public virtual string Description { get; set; }
63-
public ICollection<Project> Projects { get; set; }
63+
public virtual ICollection<Project> Projects { get; set; }
6464
}
6565
}

TakeMyTime.Tests.Common/CreateUpdateParams.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public class ProjectTypeCreateParam : ProjectType.ICreateParam
7070
public string Description { get; set; }
7171
}
7272

73+
public class ProjectTypeUpdateParam: ProjectTypeCreateParam { }
74+
7375
public class SubtaskUpdateParam : SubtaskCreateParam, Subtask.IUpdateParam { }
7476
}
7577
}

TakeMyTime.WPF/Entries/EntryOverview.xaml

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,30 @@
7171
</StackPanel>
7272
<!--<StackPanel Grid.Row="2"
7373
Orientation="Vertical">-->
74-
<ScrollViewer Grid.Row="2"
75-
IsEnabled="True">
76-
<DataGrid x:Name="lv_Entries"
74+
<ListView x:Name="lv_Entries"
7775
SelectionChanged="lv_Entries_SelectionChanged"
78-
Grid.Row="2"
79-
CanUserSortColumns="True"
80-
CanUserAddRows="False"
81-
AutoGenerateColumns="False">
82-
<DataGrid.Columns>
83-
<DataGridTextColumn Header="{x:Static resources:EntryOverview.ColumnName}" Binding="{Binding Path=Name}">
84-
</DataGridTextColumn>
85-
<DataGridTextColumn Header="{x:Static resources:EntryOverview.ColumnDescription}" Binding="{Binding Path=Description}">
86-
</DataGridTextColumn>
87-
<DataGridTextColumn Header="{x:Static resources:EntryOverview.ColumnStart}" Binding="{Binding Path=StartAsString}">
88-
</DataGridTextColumn>
89-
<DataGridTextColumn Header="{x:Static resources:EntryOverview.ColumnEnd}" Binding="{Binding Path=EndAsString}">
90-
</DataGridTextColumn>
91-
<DataGridTextColumn Header="{x:Static resources:EntryOverview.ColumnDuration}" Binding="{Binding Path=DurationAsString}">
92-
</DataGridTextColumn>
93-
<DataGridTextColumn Header="{x:Static resources:EntryOverview.ColumnProject}" Binding="{Binding Path=ProjectName}">
94-
</DataGridTextColumn>
95-
<DataGridTextColumn Header="{x:Static resources:EntryOverview.ColumnSubtask}" Binding="{Binding Path=SubtaskName}">
96-
</DataGridTextColumn>
97-
</DataGrid.Columns>
98-
</DataGrid>
99-
</ScrollViewer>
76+
Grid.Row="2" Background="{StaticResource BackgroundGrey}" Foreground="{StaticResource LightWhite}">
77+
<ListView.View>
78+
<GridView>
79+
<GridView.Columns>
80+
<GridViewColumn Header="{x:Static resources:EntryOverview.ColumnName}" DisplayMemberBinding="{Binding Path=Name}">
81+
</GridViewColumn>
82+
<GridViewColumn Header="{x:Static resources:EntryOverview.ColumnDescription}" DisplayMemberBinding="{Binding Path=Description}">
83+
</GridViewColumn>
84+
<GridViewColumn Header="{x:Static resources:EntryOverview.ColumnStart}" DisplayMemberBinding="{Binding Path=StartAsString}">
85+
</GridViewColumn>
86+
<GridViewColumn Header="{x:Static resources:EntryOverview.ColumnEnd}" DisplayMemberBinding="{Binding Path=EndAsString}">
87+
</GridViewColumn>
88+
<GridViewColumn Header="{x:Static resources:EntryOverview.ColumnDuration}" DisplayMemberBinding="{Binding Path=DurationAsString}">
89+
</GridViewColumn>
90+
<GridViewColumn Header="{x:Static resources:EntryOverview.ColumnProject}" DisplayMemberBinding="{Binding Path=ProjectName}">
91+
</GridViewColumn>
92+
<GridViewColumn Header="{x:Static resources:EntryOverview.ColumnSubtask}" DisplayMemberBinding="{Binding Path=SubtaskName}">
93+
</GridViewColumn>
94+
</GridView.Columns>
95+
</GridView>
96+
</ListView.View>
97+
</ListView>
10098
<!--</StackPanel>-->
10199
</Grid>
102100
</Page>

TakeMyTime.WPF/MainWindow.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Windows.Input;
88
using TakeMyTime.DAL;
99
using TakeMyTime.DAL.uow;
10+
using TakeMyTime.WPF.ProjectTypes;
1011
using TakeMyTime.WPF.Statistics;
1112
using TakeMyTime.WPF.Utility;
1213

@@ -124,7 +125,7 @@ private void btn_Dashboard_Click(object sender, RoutedEventArgs e)
124125

125126
private void btn_Settings_Click(object sender, RoutedEventArgs e)
126127
{
127-
fr_Content.Navigate(null);
128+
fr_Content.Navigate(new ProjectTypeOverview());
128129
}
129130

130131
#endregion

0 commit comments

Comments
 (0)