Skip to content

Commit 003abb4

Browse files
committed
Initial submission
1 parent b765889 commit 003abb4

12 files changed

Lines changed: 853 additions & 0 deletions

File tree

ShiftSharp.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27004.2005
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShiftSharp", "ShiftSharp\ShiftSharp.csproj", "{0D3FF948-F5BE-4338-94CB-CDC1A4475159}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {92ECC4BD-273F-4A11-AF59-0679537C632C}
24+
EndGlobalSection
25+
EndGlobal

ShiftSharp/Break.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2016 Kent Randall
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
26+
using NodaTime;
27+
28+
namespace Point85.ShiftSharp.Schedule
29+
{
30+
/// <summary>
31+
/// Class Break is a defined working period of time during a shift, for example lunch.
32+
/// </summary>
33+
public class Break : TimePeriod
34+
{
35+
public Break(string name, string description, LocalTime start, Duration duration) : base(name, description, start, duration)
36+
{
37+
38+
}
39+
40+
public override bool IsWorkingPeriod()
41+
{
42+
return true;
43+
}
44+
}
45+
}

ShiftSharp/DayOff.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2016 Kent Randall
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
26+
using NodaTime;
27+
28+
namespace Point85.ShiftSharp.Schedule
29+
{
30+
/// <summary>
31+
/// Class DayOff represents a scheduled non-working period
32+
/// </summary>
33+
internal class DayOff : TimePeriod
34+
{
35+
// Construct a period of time when not working
36+
DayOff(string name, string description, LocalTime start, Duration duration) : base(name, description, start, duration)
37+
{
38+
}
39+
40+
public override bool IsWorkingPeriod()
41+
{
42+
return false;
43+
}
44+
}
45+
}

ShiftSharp/Named.cs

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2016 Kent Randall
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
26+
using System;
27+
28+
namespace Point85.ShiftSharp.Schedule
29+
{
30+
/// <summary>
31+
/// Class Named represents a named object such as a Shift or Team.
32+
/// </summary>
33+
public abstract class Named
34+
{
35+
// name
36+
private string name;
37+
38+
// description
39+
private string description;
40+
41+
// database primary key
42+
private int primaryKey;
43+
44+
protected Named()
45+
{
46+
47+
}
48+
49+
protected Named(string name, string description)
50+
{
51+
SetName(name);
52+
SetDescription(description);
53+
}
54+
55+
/// <summary>
56+
/// Get name
57+
/// </summary>
58+
/// <returns>Name</returns>
59+
public string GetName()
60+
{
61+
return name;
62+
}
63+
64+
/// <summary>
65+
/// Set name
66+
/// </summary>
67+
/// <param name="name">Name</param>
68+
public void SetName(string name)
69+
{
70+
if (name == null)
71+
{
72+
throw new Exception(WorkSchedule.GetMessage("name.not.defined"));
73+
}
74+
this.name = name;
75+
}
76+
77+
/// <summary>
78+
/// Get description
79+
/// </summary>
80+
/// <returns>Description</returns>
81+
public string GetDescription()
82+
{
83+
return description;
84+
}
85+
86+
/// <summary>
87+
/// Set description
88+
/// </summary>
89+
/// <param name="description"> Description</param>
90+
public void SetDescription(string description)
91+
{
92+
this.description = description;
93+
}
94+
95+
/// <summary>
96+
/// Check for equality
97+
/// </summary>
98+
/// <param name="other">other Quantity</param>
99+
/// <returns>True if equal</returns>
100+
public override bool Equals(Object other)
101+
{
102+
103+
if (other == null || GetType() != other.GetType())
104+
{
105+
return false;
106+
}
107+
108+
return GetName().Equals(((Named)other).GetName());
109+
}
110+
111+
/// <summary>
112+
/// Compute a hash code
113+
/// </summary>
114+
/// <returns>Hash code</returns>
115+
public override int GetHashCode()
116+
{
117+
return GetName().GetHashCode();
118+
}
119+
120+
/// <summary>
121+
/// Get a string representation of a named object
122+
/// </summary>
123+
/// <returns>String value</returns>
124+
public override string ToString()
125+
{
126+
return GetName() + " (" + GetDescription() + ")";
127+
}
128+
}
129+
}

0 commit comments

Comments
 (0)