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

Commit ebdef8c

Browse files
authored
Merge pull request #45 from BinderDyn/develop
2.1.0
2 parents d6a5b6b + fd69c01 commit ebdef8c

File tree

62 files changed

+1135
-192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1135
-192
lines changed
0 Bytes
Binary file not shown.

.vs/TakeMyTime.NETCore/v16/.suo

2.5 KB
Binary file not shown.

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# TakeMyTime.NETCore
22

3-
Managing your productive time was never that easy! Display statistics, measure your progress and get things done!
3+
"Managing your productive time was never that easy! Display statistics, measure your progress and get things done!"
44

5+
This project was originally created to experiment with .NET Core 3.1 and WPF. It does NOT follow best practices or common knowledge about MVVM-Patterns. It barely implements them but was intended as a playground. If you plan to use this software for your own work and you are eager to improve it, contact me or issue a pull request. I'll be happy for each found bug or new feature I haven't thought of. I do not earn money with this piece of software and do not intend to do so. If you like it and want to honor my effort just let me know. I won't be receiving donations but would be happy if you would donate to charity instead!
6+
7+
Starting guide: https://github.com/BinderDyn/TakeMyTime.NETCore/wiki/Getting-started
58

6-
## THIRD PARTY LICENSES
79

10+
## THIRD PARTY LICENSES
811

912
This app uses MATERIAL ICONS - Licensed under the Apache License, Version 2.0 (the "License");
1013
you may not use this file except in compliance with the License.

TakeMyTime.BLL.Tests/ProjectLogicTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ private void CreateProjectWithEntries()
105105
}),
106106
};
107107

108+
foreach (var entry in entries)
109+
{
110+
entry.CalculateDuration();
111+
}
112+
108113
this.uow.Entries.AddRange(entries);
109114
this.uow.Complete();
110115
}

TakeMyTime.BLL/Logic/StatisticsLogic.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ public StatisticsLogic(UnitOfWork uow = null)
2727
}
2828
}
2929

30-
public Dictionary<string, double> GetAssignmentSharesOfProject(int project_id)
30+
public IEnumerable<Tuple<int, string, double>> GetAssignmentSharesOfProject(int project_id)
3131
{
3232
return this.unitOfWork.Statistics.GetAssignmentSharesOfProject(project_id);
3333
}
3434

35-
public Dictionary<string, double> GetProjectShares()
35+
public IEnumerable<Tuple<int, string, double>> GetProjectShares()
3636
{
3737
return this.unitOfWork.Statistics.GetProjectTotalShares();
3838
}

TakeMyTime.BLL/Logic/SubtaskLogic.cs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Common.Enums;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
@@ -41,13 +42,25 @@ public void Update(int id, Subtask.IUpdateParam param)
4142
unitOfWork.Complete();
4243
}
4344

44-
public void AddEntry(int subtask_id, Entry.ICreateParam param)
45+
public Entry AddEntry(int subtask_id, Entry.ICreateParam param, bool finishesSubtask = false)
4546
{
4647
var entry = Entry.Create(param);
4748
entry.Subtask_Id = subtask_id;
4849
var subtask = unitOfWork.Subtasks.GetSubtaskFullyLoaded(subtask_id);
49-
subtask.Entries.Add(entry);
50+
if (subtask != null)
51+
{
52+
subtask.Entries.Add(entry);
53+
if (finishesSubtask)
54+
{
55+
subtask.SetStatus(EnumDefinition.SubtaskStatus.Done);
56+
}
57+
}
58+
else
59+
{
60+
unitOfWork.Entries.Add(entry);
61+
}
5062
unitOfWork.Complete();
63+
return entry;
5164
}
5265

5366
public void Delete(int subtask_id)
@@ -57,6 +70,20 @@ public void Delete(int subtask_id)
5770
unitOfWork.Complete();
5871
}
5972

73+
public void SetSubtaskTickedOff(int subtask_id)
74+
{
75+
var subtask = unitOfWork.Subtasks.Get(subtask_id);
76+
subtask.SetStatus(EnumDefinition.SubtaskStatus.Done);
77+
unitOfWork.Complete();
78+
}
79+
80+
public void SetSubtaskAborted(int subtask_id)
81+
{
82+
var subtask = unitOfWork.Subtasks.Get(subtask_id);
83+
subtask.SetStatus(EnumDefinition.SubtaskStatus.Aborted);
84+
unitOfWork.Complete();
85+
}
86+
6087
public void Dispose()
6188
{
6289
unitOfWork.Dispose();

TakeMyTime.Common/Enums/EnumDefinition.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,23 @@ public class EnumDefinition
1515
/// <summary>
1616
/// Status of assignments
1717
/// </summary>
18+
[Flags]
1819
public enum AssignmentStatus
1920
{
20-
[Description("All")]
21-
Default = ~0,
22-
[Description("Active")]
23-
InProgress = 0,
21+
[Description("None")]
22+
None = 0,
2423
[Description("Future")]
2524
Future = 1,
25+
[Description("Active")]
26+
InProgress = 2,
2627
[Description("Done")]
27-
Done = 2,
28+
Done = 4,
2829
[Description("Aborted")]
29-
Aborted = 3,
30+
Aborted = 8,
3031
[Description("Postponed")]
31-
Postponed = 4,
32+
Postponed = 16,
33+
[Description("All")]
34+
All = ~0
3235
}
3336

3437
public enum TimekeeperStatus
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
12+
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
13+
<PackageReference Include="coverlet.collector" Version="1.0.1" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\TakeMyTime.DAL\TakeMyTime.DAL.csproj" />
18+
<ProjectReference Include="..\TakeMyTime.Models\TakeMyTime.Models.csproj" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System;
3+
using System.Linq;
4+
using TakeMyTime.Models.Models;
5+
6+
namespace TakeMyTime.DAL.Tests
7+
{
8+
[TestClass]
9+
public class WeekdayProductivityManagerTests
10+
{
11+
private WeekdayProductivityManager manager;
12+
13+
[TestInitialize]
14+
public void Initialize()
15+
{
16+
this.manager = new WeekdayProductivityManager();
17+
}
18+
19+
private Entry[] GenerateEntries()
20+
{
21+
return new Entry[]
22+
{
23+
new Entry
24+
{
25+
DurationAsTicks = TimeSpan.FromHours(1).Ticks,
26+
Started = new DateTime(2020, 3, 16)
27+
},
28+
new Entry
29+
{
30+
DurationAsTicks = TimeSpan.FromHours(1).Ticks,
31+
Started = new DateTime(2020, 3, 17)
32+
},
33+
new Entry
34+
{
35+
DurationAsTicks = TimeSpan.FromHours(1).Ticks,
36+
Started = new DateTime(2020, 3, 10)
37+
},
38+
new Entry
39+
{
40+
DurationAsTicks = TimeSpan.FromHours(1).Ticks,
41+
Started = new DateTime(2020, 3, 18)
42+
},
43+
new Entry
44+
{
45+
DurationAsTicks = TimeSpan.FromHours(1).Ticks,
46+
Started = new DateTime(2020, 3, 19)
47+
},
48+
new Entry
49+
{
50+
DurationAsTicks = TimeSpan.FromHours(1).Ticks,
51+
Started = new DateTime(2020, 3, 20)
52+
}
53+
};
54+
}
55+
56+
[TestMethod]
57+
public void TestDayWithoutEntries()
58+
{
59+
// ARRANGE
60+
var entries = this.GenerateEntries();
61+
62+
// ACT
63+
foreach (var entry in entries)
64+
{
65+
this.manager.ProcessEntry(entry);
66+
}
67+
var result = this.manager.GetResults();
68+
69+
// ASSERT
70+
double expectedTotalResultMonday = 0;
71+
double expectedAverageHoursMonday = 0;
72+
double expectedShareMonday = 0;
73+
74+
Assert.AreNotEqual(expectedTotalResultMonday, result.Single(r => r.Day == DayOfWeek.Monday).TotalHours);
75+
Assert.AreNotEqual(expectedAverageHoursMonday, result.Single(r => r.Day == DayOfWeek.Monday).AverageHours);
76+
Assert.AreNotEqual(expectedShareMonday, result.Single(r => r.Day == DayOfWeek.Monday).Value);
77+
}
78+
79+
[TestMethod]
80+
public void TestDayWithEntries()
81+
{
82+
// ARRANGE
83+
var entries = this.GenerateEntries();
84+
85+
// ACT
86+
foreach (var entry in entries)
87+
{
88+
this.manager.ProcessEntry(entry);
89+
}
90+
var result = this.manager.GetResults();
91+
92+
// ASSERT
93+
double expectedTotalResultTuesday = 2;
94+
double expectedAverageHoursTuesday = 1;
95+
double expectedShareTuesday = 33; // 100 / 6 = 16,7 => 16,7 x 2 ~ 33
96+
double expectedShareWednesday = 17;
97+
98+
Assert.AreEqual(expectedTotalResultTuesday, result.Single(r => r.Day == DayOfWeek.Tuesday).TotalHours);
99+
Assert.AreEqual(expectedAverageHoursTuesday, result.Single(r => r.Day == DayOfWeek.Tuesday).AverageHours);
100+
double roundedResultOfTuesdayShares = result.Where(r => r.Day == DayOfWeek.Tuesday).Sum(d => Math.Round(d.Value * 100));
101+
Assert.AreEqual(expectedShareTuesday, roundedResultOfTuesdayShares);
102+
double roundedResultOfWednesdayShares = Math.Round(result.Single(r => r.Day == DayOfWeek.Wednesday).Value * 100, 1);
103+
Assert.AreEqual(expectedShareWednesday, roundedResultOfWednesdayShares);
104+
}
105+
}
106+
}

TakeMyTime.DAL/Interfaces/IStatisticsRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public interface IStatisticsRepository
99
{
1010
long? GetTotalWorktimeOfAllActiveProjects();
1111
long? GetTotalWorktimeOfSpecificProject(int project_id);
12-
Dictionary<string, double> GetAssignmentSharesOfProject(int project_id);
13-
Dictionary<string, double> GetProjectTotalShares();
12+
IEnumerable<Tuple<int, string, double>> GetAssignmentSharesOfProject(int project_id);
13+
IEnumerable<Tuple<int, string, double>> GetProjectTotalShares();
1414
IEnumerable<ProductivityViewModel> GetProjectProductiveDays(int project_id);
1515
IEnumerable<MostProductiveWeekDaysViewModel> GetMostProductiveDays();
1616
}

0 commit comments

Comments
 (0)