Skip to content

Commit

Permalink
further error fixes to server project
Browse files Browse the repository at this point in the history
  • Loading branch information
JMyrtue committed Nov 22, 2023
1 parent a9cf22b commit 3b4b3b7
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 4 deletions.
27 changes: 27 additions & 0 deletions GirafEntities/Settings/DTOs/DTOs/ChangePasswordDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.ComponentModel.DataAnnotations;

namespace GirafRest.Models.DTOs.AccountDTOs
{
/// <summary>
/// DTO Used for changing password
/// </summary>
public class ChangePasswordDTO
{
/// <summary>
/// The users current password.
/// </summary>
[Required]
[DataType(DataType.Password)]
[Display(Name = "Current password")]
public string OldPassword { get; set; }

/// <summary>
/// The desired password.
/// </summary>
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
}
}
22 changes: 22 additions & 0 deletions GirafEntities/Settings/DTOs/DTOs/ResetPasswordDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;

namespace GirafRest.Models.DTOs.AccountDTOs
{
/// <summary>
/// This class defines the structure of the expected json when a user wishes to reset his password.
/// </summary>
public class ResetPasswordDTO
{
/// <summary>
/// The users password.
/// </summary>
[Required]
[DataType(DataType.Password)]
public string Password { get; set; }

/// <summary>
/// Reset password token. Used when a user request a password reset.
/// </summary>
public string Token { get; set; }
}
}
13 changes: 13 additions & 0 deletions GirafEntities/Settings/DTOs/DTOs/ResourceIdDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace GirafRest.Models.DTOs
{
/// <summary>
/// Simple DTO for a Resource ID
/// </summary>
public class ResourceIdDTO
{
/// <summary>
/// The Id of the Resource.
/// </summary>
public long? Id { get; set; }
}
}
251 changes: 251 additions & 0 deletions GirafEntities/Settings/DTOs/SettingDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace GirafRest.Models.DTOs
{
/// <summary>
/// Screen orientation
/// </summary>
public enum Orientation
{
/// <summary>
/// Portrait mode
/// </summary>
portrait = 1,

/// <summary>
/// Landscape mode
/// </summary>
landscape = 2
}
/// <summary>
/// Mark used for "Complete"
/// </summary>
public enum CompleteMark
{
/// <summary>
/// Removed X
/// </summary>
Removed = 1,
/// <summary>
/// Checkmark
/// </summary>
Checkmark = 2,
/// <summary>
/// Moved right
/// </summary>
MovedRight = 3
}

/// <summary>
/// Mark used for Cancel
/// </summary>
public enum CancelMark
{
/// <summary>
/// Removed when cancelled
/// </summary>
Removed = 1,
/// <summary>
/// X when cancelled
/// </summary>
Cross = 2
}

/// <summary>
/// Default timer type
/// </summary>
public enum DefaultTimer
{
/// <summary>
/// Hourglass model
/// </summary>
hourglass = 1,
/// <summary>
/// Piechart counting down
/// </summary>
pieChart = 2,
/// <summary>
/// Numeric Clock counting down
/// </summary>
numeric = 3
}

/// <summary>
/// Timer Theme
/// </summary>
public enum Theme
{
/// <summary>
/// Yellow as Giraf Theme
/// </summary>
girafYellow = 1,
/// <summary>
/// The theme Green
/// </summary>
girafGreen = 2,
/// <summary>
/// The Giraf Red Color
/// </summary>
girafRed = 3,
/// <summary>
/// Generic blue Android
/// </summary>
androidBlue = 4
}

/// <summary>
/// A Data Transfer Object for the user settings used by the launcher
/// </summary>
public class SettingDTO
{
/// <summary>
/// Preferred orientation of device/screen
/// </summary>
[Required]
public Orientation Orientation { get; set; }
/// <summary>
/// Preferred appearence of checked resources
/// </summary>
[Required]
public CompleteMark CompleteMark { get; set; }
/// <summary>
/// Preferred appearence of cancelled resources
/// </summary>
[Required]
public CancelMark CancelMark { get; set; }
/// <summary>
/// Preferred appearence of timer
/// </summary>
[Required]
public DefaultTimer DefaultTimer { get; set; }
/// <summary>
/// Number of seconds for timer
/// </summary>
public int? TimerSeconds { get; set; }
/// <summary>
/// Number of activities
/// </summary>
public int? ActivitiesCount { get; set; }
/// <summary>
/// The preferred theme
/// </summary>
[Required]
public Theme Theme { get; set; }
/// <summary>
/// Defines the number of days to display in portrait mode for a user in a weekplan
/// </summary>
public int? NrOfDaysToDisplayPortrait { get; set; }
/// <summary>
/// Defines the number of days to display in landscape mode for a user in a weekplan
/// </summary>
public int? NrOfDaysToDisplayLandscape { get; set; }

/// <summary>
/// true: if the first day shown in the weekplanner in landscape mode
/// should be today
/// false: if the first day shown in the weekplanner in landscape mode
/// should be monday
/// </summary>
public bool DisplayDaysRelativeLandscape { get; set; }

/// <summary>
/// true: if the first day shown in the weekplanner in portrait mode
/// should be today
/// false: if the first day shown in the weekplanner in portrait mode
/// should be monday
/// </summary>
public bool DisplayDaysRelativePortrait { get; set; }
/// <summary>
/// Flag for indicating whether or not greyscale is enabled
/// </summary>
public bool GreyScale { get; set; }
/// <summary>
/// Flag for indicating whether or not timer buttons are enabled
/// </summary>
public bool LockTimerControl { get; set; }
/// <summary>
/// Flag for indicating whether or not pictogram text is enabled
/// </summary>
public bool PictogramText { get; set; }
/// <summary>
/// Flag for indicating whether or not popup is enabled
/// </summary>
public bool ShowPopup { get; set; }
/// <summary>
/// Defines the number of activities to display for a user in a weekschedule
/// </summary>
public int? NrOfActivitiesToDisplay { get; set; }
/// <summary>
/// Flag to indicate whether citizen should see one or more days or only activities
/// </summary>
public bool ShowOnlyActivities { get; set; }
/// <summary>
/// Flag for indicating whether or not settings are shown to a citizen
/// </summary>
public bool ShowSettingsForCitizen { get; set; }

/// <summary>
/// List of weekday colors
/// </summary>
public List<WeekDayColorDTO> WeekDayColors { get; set; }
/// <summary>
/// Constructor to create a DTO based on the actual object
/// </summary>
/// <param name="options">The launcher options in need of transfer</param>
public SettingDTO(Setting options)
{
this.Orientation = options.Orientation;
this.CompleteMark = options.CompleteMark;
this.CancelMark = options.CancelMark;
this.DefaultTimer = options.DefaultTimer;
this.TimerSeconds = options.TimerSeconds;
this.ActivitiesCount = options.ActivitiesCount;
this.Theme = options.Theme;
this.NrOfDaysToDisplayPortrait = options.NrOfDaysToDisplayPortrait;
this.DisplayDaysRelativePortrait = options.DisplayDaysRelativePortrait;
this.NrOfDaysToDisplayLandscape = options.NrOfDaysToDisplayLandscape;
this.DisplayDaysRelativeLandscape = options.DisplayDaysRelativeLandscape;
this.ShowOnlyActivities = options.ShowOnlyActivities;
this.NrOfActivitiesToDisplay = options.NrOfActivitiesToDisplay;
this.GreyScale = options.GreyScale;
this.LockTimerControl = options.LockTimerControl;
this.PictogramText = options.PictogramText;
this.ShowSettingsForCitizen = options.ShowSettingsForCitizen;
this.WeekDayColors = SetWeekDayColorsFromModel(options.WeekDayColors);
this.ShowPopup = options.ShowPopup;
}

/// <summary>
/// Empty Constructor used for JSON Generation
/// </summary>
public SettingDTO()
{
Orientation = Orientation.portrait;
CompleteMark = CompleteMark.Checkmark;
CancelMark = CancelMark.Cross;
DefaultTimer = DefaultTimer.pieChart;
Theme = Theme.girafYellow;
}

private List<WeekDayColorDTO> SetWeekDayColorsFromModel(List<WeekDayColor> weekDayColors)
{
if (weekDayColors != null)
{
var WeekDayColorDTOs = new List<WeekDayColorDTO>();
foreach (var weekDayColor in weekDayColors)
{
WeekDayColorDTOs.Add(new WeekDayColorDTO()
{
Day = weekDayColor.Day,
HexColor = weekDayColor.HexColor
});
}

return WeekDayColorDTOs;
}

return null;
}
}
}
13 changes: 13 additions & 0 deletions GirafEntities/WeekPlanner/DTOs/ResourceIdDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace GirafRest.Models.DTOs
{
/// <summary>
/// Simple DTO for a Resource ID
/// </summary>
public class ResourceIdDTO
{
/// <summary>
/// The Id of the Resource.
/// </summary>
public long? Id { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using GirafEntities.User;
using GirafEntities.WeekPlanner;
using GirafRest.Models;

namespace GirafRepositories.Interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using GirafEntities.User;
using GirafEntities.WeekPlanner;
using GirafRest.Models;

namespace GirafRepositories.Interfaces
Expand Down
6 changes: 4 additions & 2 deletions GirafServices/GirafServices.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\GirafRepositories\GirafRepositories.csproj" />
<Compile Remove="Sample\**" />
<EmbeddedResource Remove="Sample\**" />
<None Remove="Sample\**" />
</ItemGroup>

<ItemGroup>
<Folder Include="Sample\" />
<ProjectReference Include="..\GirafRepositories\GirafRepositories.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions GirafServices/WeekPlanner/WeekBaseService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using GirafEntities.WeekPlanner;
using Microsoft.SqlServer.Management.Smo.Agent;

namespace GirafServices.WeekPlanner
{
Expand All @@ -11,7 +10,7 @@ public class WeekBaseService
/// <param name="day">A day instance to update the week with - the old one is completely overridden.</param>
public void UpdateDay(Weekday day)
{
var wd = WeekDays.FirstOrDefault(d => d.Day == day.Day);
var wd = Weekdays.FirstOrDefault(d => d.Day == day.Day);
if (wd == null)
Weekdays.Add(day);
else
Expand Down

0 comments on commit 3b4b3b7

Please sign in to comment.