diff --git a/Project.Zap/Controllers/ShiftsController.cs b/Project.Zap/Controllers/ShiftsController.cs index f272633..f22a267 100644 --- a/Project.Zap/Controllers/ShiftsController.cs +++ b/Project.Zap/Controllers/ShiftsController.cs @@ -116,7 +116,7 @@ namespace Project.Zap.Controllers private async Task Search(SearchShiftViewModel search, IEnumerable locations) { - List locationIds = new List(); + List locationIds = new List(); if (search.Locations != null && search.Locations.Any()) { @@ -346,6 +346,7 @@ namespace Project.Zap.Controllers if (!ModelState.IsValid) { this.logger.LogError("Add shift view model is not valid"); + viewModel.LocationNames = this.GetLocationNames(await this.locationService.Get()); return View("Add", viewModel); } diff --git a/Project.Zap/Filters/DateMustBeEqualOrGreaterThanCurrentAttribute.cs b/Project.Zap/Filters/DateMustBeEqualOrGreaterThanCurrentAttribute.cs index 4bb07d1..8e6d4b0 100644 --- a/Project.Zap/Filters/DateMustBeEqualOrGreaterThanCurrentAttribute.cs +++ b/Project.Zap/Filters/DateMustBeEqualOrGreaterThanCurrentAttribute.cs @@ -18,7 +18,7 @@ namespace Project.Zap.Filters ErrorMessage = ErrorMessageString; DateTime currentValue = (DateTime)value; - if (currentValue <= DateTime.Today) + if (currentValue <= DateTime.Now) { return new ValidationResult(ErrorMessage); } diff --git a/Project.Zap/Models/ShiftViewModel.cs b/Project.Zap/Models/ShiftViewModel.cs index 0b7f76e..a28c6b8 100644 --- a/Project.Zap/Models/ShiftViewModel.cs +++ b/Project.Zap/Models/ShiftViewModel.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.ApplicationInsights.AspNetCore; +using Microsoft.AspNetCore.Mvc; using Project.Zap.Filters; using System; using System.ComponentModel.DataAnnotations; @@ -28,13 +29,12 @@ namespace Project.Zap.Models public DateTime End { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0); [BindProperty] - [Required] + [Required(ErrorMessageResourceName ="WorkTypeRequired", ErrorMessageResourceType = typeof(Zap.Properties.Resources))] [Display(Name = "WorkType")] public string WorkType { get; set; } [BindProperty] - [Required] - [Range(1, 200)] + [Range(1, 200, ErrorMessageResourceName ="QuantityRange", ErrorMessageResourceType =typeof(Zap.Properties.Resources))] [Display(Name = "Quantity")] public int Quantity { get; set; } diff --git a/Project.Zap/Project.Zap.csproj b/Project.Zap/Project.Zap.csproj index 046a7e3..8cd0e8a 100644 --- a/Project.Zap/Project.Zap.csproj +++ b/Project.Zap/Project.Zap.csproj @@ -22,6 +22,28 @@ + + + True + True + Resources.en-US.resx + + + + + + ResXFileCodeGenerator + Resources.en-US.Designer.cs + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + + + + diff --git a/Project.Zap/Properties/Resources.en-US.Designer.cs b/Project.Zap/Properties/Resources.en-US.Designer.cs new file mode 100644 index 0000000..9004db5 --- /dev/null +++ b/Project.Zap/Properties/Resources.en-US.Designer.cs @@ -0,0 +1,80 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Project.Zap.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Project.Zap.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Error quantity. + /// + internal static string QuantityRange { + get { + return ResourceManager.GetString("QuantityRange", resourceCulture); + } + } + + internal static string WorkTypeRequired + { + get + { + return ResourceManager.GetString("WorkTypeRequired", resourceCulture); + } + } + } +} diff --git a/Project.Zap/Properties/Resources.en-US.resx b/Project.Zap/Properties/Resources.en-US.resx new file mode 100644 index 0000000..835c02f --- /dev/null +++ b/Project.Zap/Properties/Resources.en-US.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + The field Quantity must be between 1 and 200 + + + The Work Type field is required + + \ No newline at end of file diff --git a/Project.Zap/Properties/Resources.fr.resx b/Project.Zap/Properties/Resources.fr.resx new file mode 100644 index 0000000..6cdfee7 --- /dev/null +++ b/Project.Zap/Properties/Resources.fr.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Quantité doit être compris entre 1 et 200 + + + Type de travail est requis + + \ No newline at end of file diff --git a/Project.Zap/Views/Shifts/Add.cshtml b/Project.Zap/Views/Shifts/Add.cshtml index 93af36a..559decc 100644 --- a/Project.Zap/Views/Shifts/Add.cshtml +++ b/Project.Zap/Views/Shifts/Add.cshtml @@ -42,6 +42,7 @@ @section Scripts { } \ No newline at end of file