diff --git a/Disco.Data/Disco.Data.csproj b/Disco.Data/Disco.Data.csproj index 096241c3..e35c82ed 100644 --- a/Disco.Data/Disco.Data.csproj +++ b/Disco.Data/Disco.Data.csproj @@ -166,7 +166,7 @@ - + diff --git a/Disco.Data/Repository/DiscoDataContext.cs b/Disco.Data/Repository/DiscoDataContext.cs index 77883599..fa939189 100644 --- a/Disco.Data/Repository/DiscoDataContext.cs +++ b/Disco.Data/Repository/DiscoDataContext.cs @@ -65,7 +65,6 @@ namespace Disco.Data.Repository modelBuilder.Entity().HasMany(m => m.JobSubTypes).WithMany(m => m.Jobs).Map(m => m.ToTable("Jobs_JobSubTypes")); modelBuilder.Entity().HasMany(m => m.Jobs).WithOptional(m => m.User); modelBuilder.Entity().HasMany(m => m.Jobs).WithOptional(m => m.Device); - modelBuilder.Entity().Property(DeviceProfile.PropertyAccessExpressions.DistributionTypeDb); } // Hook for Repository Monitor diff --git a/Disco.Models/Repository/Device/DeviceProfile.cs b/Disco.Models/Repository/Device/DeviceProfile.cs index 628e98d7..9bdad558 100644 --- a/Disco.Models/Repository/Device/DeviceProfile.cs +++ b/Disco.Models/Repository/Device/DeviceProfile.cs @@ -27,27 +27,12 @@ namespace Disco.Models.Repository // Migration from DeviceProfile Configuration // 2012-06-14 G# - [Required()] + [Required] public string ComputerNameTemplate { get; set; } - public enum DistributionTypes : int - { - OneToMany = 0, - OneToOne = 1 - } - [Column("DistributionType"), EditorBrowsable(EditorBrowsableState.Never)] - public int DistributionTypeDb { get; set; } - [NotMapped] - public DistributionTypes DistributionType - { - get - { - return (DistributionTypes)this.DistributionTypeDb; - } - set - { - this.DistributionTypeDb = (int)value; - } - } + + [Required] + public DistributionTypes? DistributionType { get; set; } + public string OrganisationalUnit { get; set; } // End Migration @@ -73,11 +58,11 @@ namespace Disco.Models.Repository // public bool AllocateCertificate { get; set; } // Renamed from 'AllocateWirelessCertificate' [StringLength(64)] public string CertificateProviderId { get; set; } - } - public partial class DeviceProfile - { - public class PropertyAccessExpressions { - public static readonly Expression> DistributionTypeDb = x => x.DistributionTypeDb; + + public enum DistributionTypes : int + { + OneToMany = 0, + OneToOne = 1 } } } diff --git a/Disco.Models/UI/Config/DeviceProfile/ConfigDeviceProfileIndexModelItem.cs b/Disco.Models/UI/Config/DeviceProfile/ConfigDeviceProfileIndexModelItem.cs index db4414d5..eac3c90c 100644 --- a/Disco.Models/UI/Config/DeviceProfile/ConfigDeviceProfileIndexModelItem.cs +++ b/Disco.Models/UI/Config/DeviceProfile/ConfigDeviceProfileIndexModelItem.cs @@ -14,9 +14,7 @@ namespace Disco.Models.UI.Config.DeviceProfile int? Address { get; set; } string AddressName { get; set; } string Description { get; set; } - int DistributionTypeId { get; set; } - - string DistributionType { get; } + Models.Repository.DeviceProfile.DistributionTypes DistributionType { get; set; } int DeviceCount { get; set; } int DeviceDecommissionedCount { get; set; } diff --git a/Disco.Web/Areas/Config/Controllers/DeviceProfileController.cs b/Disco.Web/Areas/Config/Controllers/DeviceProfileController.cs index c65bcbf5..d856f5ce 100644 --- a/Disco.Web/Areas/Config/Controllers/DeviceProfileController.cs +++ b/Disco.Web/Areas/Config/Controllers/DeviceProfileController.cs @@ -75,7 +75,8 @@ namespace Disco.Web.Areas.Config.Controllers DeviceProfile = new DeviceProfile() { ComputerNameTemplate = "DeviceProfile.ShortName + '-' + SerialNumber", - ProvisionADAccount = true + ProvisionADAccount = true, + DistributionType = DeviceProfile.DistributionTypes.OneToMany } }; diff --git a/Disco.Web/Areas/Config/Models/DeviceProfile/IndexModel.cs b/Disco.Web/Areas/Config/Models/DeviceProfile/IndexModel.cs index 8ac46937..e000e5f0 100644 --- a/Disco.Web/Areas/Config/Models/DeviceProfile/IndexModel.cs +++ b/Disco.Web/Areas/Config/Models/DeviceProfile/IndexModel.cs @@ -22,7 +22,7 @@ namespace Disco.Web.Areas.Config.Models.DeviceProfile ShortName = dp.ShortName, Address = dp.DefaultOrganisationAddress, Description = dp.Description, - DistributionTypeId = (int)dp.DistributionType, + DistributionType = dp.DistributionType.Value, DeviceCount = dp.Devices.Count, DeviceDecommissionedCount = dp.Devices.Count(d => d.DecommissionedDate.HasValue) }).ToArray().Cast().ToList(); diff --git a/Disco.Web/Areas/Config/Models/DeviceProfile/_IndexModelItem.cs b/Disco.Web/Areas/Config/Models/DeviceProfile/_IndexModelItem.cs index a0a2fb55..609cdbf6 100644 --- a/Disco.Web/Areas/Config/Models/DeviceProfile/_IndexModelItem.cs +++ b/Disco.Web/Areas/Config/Models/DeviceProfile/_IndexModelItem.cs @@ -16,15 +16,7 @@ namespace Disco.Web.Areas.Config.Models.DeviceProfile public int? Address { get; set; } public string AddressName { get; set; } public string Description { get; set; } - public int DistributionTypeId { get; set; } - - public string DistributionType - { - get - { - return Enum.GetName(typeof(Disco.Models.Repository.DeviceProfile.DistributionTypes), this.DistributionTypeId); - } - } + public Disco.Models.Repository.DeviceProfile.DistributionTypes DistributionType { get; set; } public int DeviceCount { get; set; } public int DeviceDecommissionedCount { get; set; } diff --git a/Disco.Web/Areas/Config/Views/DeviceProfile/Create.cshtml b/Disco.Web/Areas/Config/Views/DeviceProfile/Create.cshtml index 61705f4c..38eafefd 100644 --- a/Disco.Web/Areas/Config/Views/DeviceProfile/Create.cshtml +++ b/Disco.Web/Areas/Config/Views/DeviceProfile/Create.cshtml @@ -4,6 +4,7 @@ } @using (Html.BeginForm()) { + @Html.ValidationSummary(false)
@@ -31,6 +32,7 @@
@Html.HiddenFor(model => model.DeviceProfile.ComputerNameTemplate) @Html.HiddenFor(model => model.DeviceProfile.ProvisionADAccount) + @Html.HiddenFor(model => model.DeviceProfile.DistributionType)

diff --git a/Disco.Web/Areas/Config/Views/DeviceProfile/Create.generated.cs b/Disco.Web/Areas/Config/Views/DeviceProfile/Create.generated.cs index 496a21a5..9af139e0 100644 --- a/Disco.Web/Areas/Config/Views/DeviceProfile/Create.generated.cs +++ b/Disco.Web/Areas/Config/Views/DeviceProfile/Create.generated.cs @@ -2,7 +2,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18033 +// Runtime Version:4.0.30319.18051 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -54,6 +54,20 @@ WriteLiteral("\r\n"); #line 5 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" using (Html.BeginForm()) { + + + #line default + #line hidden + + #line 7 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" +Write(Html.ValidationSummary(false)); + + + #line default + #line hidden + + #line 7 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" + #line default @@ -70,7 +84,7 @@ WriteLiteral(">\r\n \r\n \r\n \r\n ">\r\n Short Name:\r\n \r\n \r\n \r\n WriteLiteral("
"); - #line 21 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" + #line 22 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" Write(Html.ValidationMessageFor(model => model.DeviceProfile.ShortName)); @@ -109,7 +123,7 @@ WriteLiteral("\r\n \r\n \r\n ""); - #line 28 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" + #line 29 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" Write(Html.TextBoxFor(model => model.DeviceProfile.Description)); @@ -118,7 +132,7 @@ WriteLiteral("\r\n \r\n \r\n WriteLiteral("
"); - #line 28 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" + #line 29 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" Write(Html.ValidationMessageFor(model => model.DeviceProfile.Description)); @@ -129,7 +143,7 @@ WriteLiteral("\r\n \r\n \r\n
\r WriteLiteral(" "); - #line 14 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" + #line 15 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" Write(Html.TextBoxFor(model => model.DeviceProfile.Name)); @@ -79,7 +93,7 @@ WriteLiteral(" "); WriteLiteral("
"); - #line 14 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" + #line 15 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" Write(Html.ValidationMessageFor(model => model.DeviceProfile.Name)); @@ -89,7 +103,7 @@ WriteLiteral("\r\n \r\n
"); - #line 21 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" + #line 22 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" Write(Html.TextBoxFor(model => model.DeviceProfile.ShortName)); @@ -98,7 +112,7 @@ WriteLiteral("\r\n
WriteLiteral(" "); - #line 32 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" + #line 33 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" Write(Html.HiddenFor(model => model.DeviceProfile.ComputerNameTemplate)); @@ -140,10 +154,21 @@ WriteLiteral("\r\n"); WriteLiteral(" "); - #line 33 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" + #line 34 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" Write(Html.HiddenFor(model => model.DeviceProfile.ProvisionADAccount)); + #line default + #line hidden +WriteLiteral("\r\n"); + +WriteLiteral(" "); + + + #line 35 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" + Write(Html.HiddenFor(model => model.DeviceProfile.DistributionType)); + + #line default #line hidden WriteLiteral("\r\n \r\n $(function () {\r\n $(\'#Name\').focus().s "\r\n \r\n"); - #line 43 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" + #line 45 "..\..\Areas\Config\Views\DeviceProfile\Create.cshtml" }