diff --git a/GirafEntities/Settings/DTOs/DTOs/ChangePasswordDTO.cs b/GirafEntities/Settings/DTOs/DTOs/ChangePasswordDTO.cs new file mode 100644 index 00000000..634f8f3d --- /dev/null +++ b/GirafEntities/Settings/DTOs/DTOs/ChangePasswordDTO.cs @@ -0,0 +1,27 @@ +using System.ComponentModel.DataAnnotations; + +namespace GirafRest.Models.DTOs.AccountDTOs +{ + /// + /// DTO Used for changing password + /// + public class ChangePasswordDTO + { + /// + /// The users current password. + /// + [Required] + [DataType(DataType.Password)] + [Display(Name = "Current password")] + public string OldPassword { get; set; } + + /// + /// The desired password. + /// + [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; } + } +} diff --git a/GirafEntities/Settings/DTOs/DTOs/ResetPasswordDTO.cs b/GirafEntities/Settings/DTOs/DTOs/ResetPasswordDTO.cs new file mode 100644 index 00000000..ed05a9cd --- /dev/null +++ b/GirafEntities/Settings/DTOs/DTOs/ResetPasswordDTO.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.DataAnnotations; + +namespace GirafRest.Models.DTOs.AccountDTOs +{ + /// + /// This class defines the structure of the expected json when a user wishes to reset his password. + /// + public class ResetPasswordDTO + { + /// + /// The users password. + /// + [Required] + [DataType(DataType.Password)] + public string Password { get; set; } + + /// + /// Reset password token. Used when a user request a password reset. + /// + public string Token { get; set; } + } +} diff --git a/GirafEntities/Settings/DTOs/DTOs/ResourceIdDTO.cs b/GirafEntities/Settings/DTOs/DTOs/ResourceIdDTO.cs new file mode 100644 index 00000000..235e1e6c --- /dev/null +++ b/GirafEntities/Settings/DTOs/DTOs/ResourceIdDTO.cs @@ -0,0 +1,13 @@ +namespace GirafRest.Models.DTOs +{ + /// + /// Simple DTO for a Resource ID + /// + public class ResourceIdDTO + { + /// + /// The Id of the Resource. + /// + public long? Id { get; set; } + } +} diff --git a/GirafEntities/Settings/DTOs/SettingDTO.cs b/GirafEntities/Settings/DTOs/SettingDTO.cs new file mode 100644 index 00000000..5dafea83 --- /dev/null +++ b/GirafEntities/Settings/DTOs/SettingDTO.cs @@ -0,0 +1,251 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace GirafRest.Models.DTOs +{ + /// + /// Screen orientation + /// + public enum Orientation + { + /// + /// Portrait mode + /// + portrait = 1, + + /// + /// Landscape mode + /// + landscape = 2 + } + /// + /// Mark used for "Complete" + /// + public enum CompleteMark + { + /// + /// Removed X + /// + Removed = 1, + /// + /// Checkmark + /// + Checkmark = 2, + /// + /// Moved right + /// + MovedRight = 3 + } + + /// + /// Mark used for Cancel + /// + public enum CancelMark + { + /// + /// Removed when cancelled + /// + Removed = 1, + /// + /// X when cancelled + /// + Cross = 2 + } + + /// + /// Default timer type + /// + public enum DefaultTimer + { + /// + /// Hourglass model + /// + hourglass = 1, + /// + /// Piechart counting down + /// + pieChart = 2, + /// + /// Numeric Clock counting down + /// + numeric = 3 + } + + /// + /// Timer Theme + /// + public enum Theme + { + /// + /// Yellow as Giraf Theme + /// + girafYellow = 1, + /// + /// The theme Green + /// + girafGreen = 2, + /// + /// The Giraf Red Color + /// + girafRed = 3, + /// + /// Generic blue Android + /// + androidBlue = 4 + } + + /// + /// A Data Transfer Object for the user settings used by the launcher + /// + public class SettingDTO + { + /// + /// Preferred orientation of device/screen + /// + [Required] + public Orientation Orientation { get; set; } + /// + /// Preferred appearence of checked resources + /// + [Required] + public CompleteMark CompleteMark { get; set; } + /// + /// Preferred appearence of cancelled resources + /// + [Required] + public CancelMark CancelMark { get; set; } + /// + /// Preferred appearence of timer + /// + [Required] + public DefaultTimer DefaultTimer { get; set; } + /// + /// Number of seconds for timer + /// + public int? TimerSeconds { get; set; } + /// + /// Number of activities + /// + public int? ActivitiesCount { get; set; } + /// + /// The preferred theme + /// + [Required] + public Theme Theme { get; set; } + /// + /// Defines the number of days to display in portrait mode for a user in a weekplan + /// + public int? NrOfDaysToDisplayPortrait { get; set; } + /// + /// Defines the number of days to display in landscape mode for a user in a weekplan + /// + public int? NrOfDaysToDisplayLandscape { get; set; } + + /// + /// 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 + /// + public bool DisplayDaysRelativeLandscape { get; set; } + + /// + /// 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 + /// + public bool DisplayDaysRelativePortrait { get; set; } + /// + /// Flag for indicating whether or not greyscale is enabled + /// + public bool GreyScale { get; set; } + /// + /// Flag for indicating whether or not timer buttons are enabled + /// + public bool LockTimerControl { get; set; } + /// + /// Flag for indicating whether or not pictogram text is enabled + /// + public bool PictogramText { get; set; } + /// + /// Flag for indicating whether or not popup is enabled + /// + public bool ShowPopup { get; set; } + /// + /// Defines the number of activities to display for a user in a weekschedule + /// + public int? NrOfActivitiesToDisplay { get; set; } + /// + /// Flag to indicate whether citizen should see one or more days or only activities + /// + public bool ShowOnlyActivities { get; set; } + /// + /// Flag for indicating whether or not settings are shown to a citizen + /// + public bool ShowSettingsForCitizen { get; set; } + + /// + /// List of weekday colors + /// + public List WeekDayColors { get; set; } + /// + /// Constructor to create a DTO based on the actual object + /// + /// The launcher options in need of transfer + 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; + } + + /// + /// Empty Constructor used for JSON Generation + /// + public SettingDTO() + { + Orientation = Orientation.portrait; + CompleteMark = CompleteMark.Checkmark; + CancelMark = CancelMark.Cross; + DefaultTimer = DefaultTimer.pieChart; + Theme = Theme.girafYellow; + } + + private List SetWeekDayColorsFromModel(List weekDayColors) + { + if (weekDayColors != null) + { + var WeekDayColorDTOs = new List(); + foreach (var weekDayColor in weekDayColors) + { + WeekDayColorDTOs.Add(new WeekDayColorDTO() + { + Day = weekDayColor.Day, + HexColor = weekDayColor.HexColor + }); + } + + return WeekDayColorDTOs; + } + + return null; + } + } +} diff --git a/GirafEntities/WeekPlanner/DTOs/ResourceIdDTO.cs b/GirafEntities/WeekPlanner/DTOs/ResourceIdDTO.cs new file mode 100644 index 00000000..235e1e6c --- /dev/null +++ b/GirafEntities/WeekPlanner/DTOs/ResourceIdDTO.cs @@ -0,0 +1,13 @@ +namespace GirafRest.Models.DTOs +{ + /// + /// Simple DTO for a Resource ID + /// + public class ResourceIdDTO + { + /// + /// The Id of the Resource. + /// + public long? Id { get; set; } + } +} diff --git a/GirafRepositories/User/Interfaces/IDepartmentResourseRepository.cs b/GirafRepositories/User/Interfaces/IDepartmentResourseRepository.cs index 75770755..32e56217 100644 --- a/GirafRepositories/User/Interfaces/IDepartmentResourseRepository.cs +++ b/GirafRepositories/User/Interfaces/IDepartmentResourseRepository.cs @@ -1,4 +1,5 @@ using GirafEntities.User; +using GirafEntities.WeekPlanner; using GirafRest.Models; namespace GirafRepositories.Interfaces diff --git a/GirafRepositories/User/Interfaces/IUserResourseRepository.cs b/GirafRepositories/User/Interfaces/IUserResourseRepository.cs index 438cb836..1bd772cb 100644 --- a/GirafRepositories/User/Interfaces/IUserResourseRepository.cs +++ b/GirafRepositories/User/Interfaces/IUserResourseRepository.cs @@ -1,4 +1,5 @@ using GirafEntities.User; +using GirafEntities.WeekPlanner; using GirafRest.Models; namespace GirafRepositories.Interfaces diff --git a/GirafServices/GirafServices.csproj b/GirafServices/GirafServices.csproj index a08fe4ba..4482eea7 100644 --- a/GirafServices/GirafServices.csproj +++ b/GirafServices/GirafServices.csproj @@ -7,11 +7,13 @@ - + + + - + diff --git a/GirafServices/WeekPlanner/WeekBaseService.cs b/GirafServices/WeekPlanner/WeekBaseService.cs index 16233fca..cbabff64 100644 --- a/GirafServices/WeekPlanner/WeekBaseService.cs +++ b/GirafServices/WeekPlanner/WeekBaseService.cs @@ -1,5 +1,4 @@ using GirafEntities.WeekPlanner; -using Microsoft.SqlServer.Management.Smo.Agent; namespace GirafServices.WeekPlanner { @@ -11,7 +10,7 @@ public class WeekBaseService /// A day instance to update the week with - the old one is completely overridden. 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