Permissions & Authorization for Users #24
Initial Release; Includes Database and MVC refactoring
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.Repository;
|
||||
using System;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Web;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web.Areas.Public.Controllers
|
||||
{
|
||||
public partial class HeldDevicesController : dbController
|
||||
public partial class HeldDevicesController : DatabaseController
|
||||
{
|
||||
#region Helpers
|
||||
|
||||
@@ -40,17 +38,17 @@ namespace Disco.Web.Areas.Public.Controllers
|
||||
{
|
||||
if (job.Any(j => j.WaitingForUserAction))
|
||||
{
|
||||
thd.Add(job.Where(j => j.WaitingForUserAction).OrderBy(j => j.WaitingForUserActionSince).FirstOrDefault().ToUserHeldDeviceModel(dbContext));
|
||||
thd.Add(job.Where(j => j.WaitingForUserAction).OrderBy(j => j.WaitingForUserActionSince).FirstOrDefault().ToUserHeldDeviceModel(Database));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (job.All(j => j.ReadyForReturn))
|
||||
{
|
||||
thd.Add(job.FirstOrDefault().ToUserHeldDeviceModel(dbContext));
|
||||
thd.Add(job.FirstOrDefault().ToUserHeldDeviceModel(Database));
|
||||
}
|
||||
else
|
||||
{
|
||||
thd.Add(job.Where(j => !j.ReadyForReturn).OrderByDescending(j => j.EstimatedReturnTime).FirstOrDefault().ToUserHeldDeviceModel(dbContext));
|
||||
thd.Add(job.Where(j => !j.ReadyForReturn).OrderByDescending(j => j.EstimatedReturnTime).FirstOrDefault().ToUserHeldDeviceModel(Database));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,11 +57,11 @@ namespace Disco.Web.Areas.Public.Controllers
|
||||
|
||||
private List<Models.HeldDevices.HeldDeviceModel> GetHeldDevices()
|
||||
{
|
||||
return GetHeldDevices(dbContext.Jobs);
|
||||
return GetHeldDevices(Database.Jobs);
|
||||
}
|
||||
private Models.HeldDevices.HeldDeviceModel GetHeldDevice(string DeviceSerialNumber)
|
||||
{
|
||||
return GetHeldDevices(dbContext.Jobs.Where(j => j.DeviceSerialNumber == DeviceSerialNumber)).FirstOrDefault();
|
||||
return GetHeldDevices(Database.Jobs.Where(j => j.DeviceSerialNumber == DeviceSerialNumber)).FirstOrDefault();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
using System;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Web;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.BI;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
|
||||
namespace Disco.Web.Areas.Public.Controllers
|
||||
{
|
||||
public partial class UserHeldDevicesController : dbController
|
||||
public partial class UserHeldDevicesController : DatabaseController
|
||||
{
|
||||
#region Helpers
|
||||
|
||||
@@ -38,17 +35,17 @@ namespace Disco.Web.Areas.Public.Controllers
|
||||
{
|
||||
if (job.Any(j => j.WaitingForUserAction))
|
||||
{
|
||||
thd.Add(job.Where(j => j.WaitingForUserAction).OrderBy(j => j.WaitingForUserActionSince).FirstOrDefault().ToUserHeldDeviceModel(dbContext));
|
||||
thd.Add(job.Where(j => j.WaitingForUserAction).OrderBy(j => j.WaitingForUserActionSince).FirstOrDefault().ToUserHeldDeviceModel(Database));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (job.All(j => j.ReadyForReturn))
|
||||
{
|
||||
thd.Add(job.FirstOrDefault().ToUserHeldDeviceModel(dbContext));
|
||||
thd.Add(job.FirstOrDefault().ToUserHeldDeviceModel(Database));
|
||||
}
|
||||
else
|
||||
{
|
||||
thd.Add(job.Where(j => !j.ReadyForReturn).OrderByDescending(j => j.EstimatedReturnTime).FirstOrDefault().ToUserHeldDeviceModel(dbContext));
|
||||
thd.Add(job.Where(j => !j.ReadyForReturn).OrderByDescending(j => j.EstimatedReturnTime).FirstOrDefault().ToUserHeldDeviceModel(Database));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,11 +56,11 @@ namespace Disco.Web.Areas.Public.Controllers
|
||||
|
||||
private List<Models.UserHeldDevices.UserHeldDeviceModel> GetUserHeldDevices()
|
||||
{
|
||||
return GetUserHeldDevices(dbContext.Jobs);
|
||||
return GetUserHeldDevices(Database.Jobs);
|
||||
}
|
||||
private Models.UserHeldDevices.UserHeldDeviceModel GetUserHeldDevice(string UserId)
|
||||
{
|
||||
return GetUserHeldDevices(dbContext.Jobs.Where(j => j.Device.AssignedUserId == UserId)).FirstOrDefault();
|
||||
return GetUserHeldDevices(Database.Jobs.Where(j => j.Device.AssignedUserId == UserId)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public virtual ActionResult Index()
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Disco.Web.Areas.Public.Models.HeldDevices
|
||||
public DateTime? ReadyForReturnSince { get; set; }
|
||||
public DateTime? WaitingForUserActionSince { get; set; }
|
||||
|
||||
public HeldDeviceModel ToUserHeldDeviceModel(DiscoDataContext dbContext)
|
||||
public HeldDeviceModel ToUserHeldDeviceModel(DiscoDataContext Database)
|
||||
{
|
||||
var uhdm = new HeldDeviceModel()
|
||||
{
|
||||
@@ -34,7 +34,7 @@ namespace Disco.Web.Areas.Public.Models.HeldDevices
|
||||
DeviceComputerName = this.DeviceComputerName,
|
||||
DeviceLocation = this.DeviceLocation,
|
||||
DeviceProfileId = this.DeviceProfileId,
|
||||
DeviceAddress = (this.DeviceAddressId.HasValue ? dbContext.DiscoConfiguration.OrganisationAddresses.GetAddress(this.DeviceAddressId.Value).ShortName : string.Empty),
|
||||
DeviceAddress = (this.DeviceAddressId.HasValue ? Database.DiscoConfiguration.OrganisationAddresses.GetAddress(this.DeviceAddressId.Value).ShortName : string.Empty),
|
||||
UserId = this.UserId,
|
||||
UserDisplayName = this.UserDisplayName,
|
||||
ReadyForReturn = this.ReadyForReturn,
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Disco.Web.Areas.Public.Models.UserHeldDevices
|
||||
public DateTime? ReadyForReturnSince { get; set; }
|
||||
public DateTime? WaitingForUserActionSince { get; set; }
|
||||
|
||||
public UserHeldDeviceModel ToUserHeldDeviceModel(DiscoDataContext dbContext)
|
||||
public UserHeldDeviceModel ToUserHeldDeviceModel(DiscoDataContext Database)
|
||||
{
|
||||
var uhdm = new UserHeldDeviceModel()
|
||||
{
|
||||
@@ -31,7 +31,7 @@ namespace Disco.Web.Areas.Public.Models.UserHeldDevices
|
||||
ReadyForReturn = this.ReadyForReturn,
|
||||
WaitingForUserAction = this.WaitingForUserAction,
|
||||
DeviceProfileId = this.DeviceProfileId,
|
||||
DeviceAddress = (this.DeviceAddressId.HasValue ? dbContext.DiscoConfiguration.OrganisationAddresses.GetAddress(this.DeviceAddressId.Value).ShortName : string.Empty)
|
||||
DeviceAddress = (this.DeviceAddressId.HasValue ? Database.DiscoConfiguration.OrganisationAddresses.GetAddress(this.DeviceAddressId.Value).ShortName : string.Empty)
|
||||
};
|
||||
var n = DateTime.Now;
|
||||
if (!this.ReadyForReturn && this.EstimatedReturnTime.HasValue && this.EstimatedReturnTime.Value > n)
|
||||
|
||||
@@ -28,12 +28,14 @@ namespace Disco.Web.Areas.Public.Views.HeldDevices
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Public/Views/HeldDevices/Index.cshtml")]
|
||||
public partial class Index : System.Web.Mvc.WebViewPage<IEnumerable<Disco.Web.Areas.Public.Models.HeldDevices.HeldDeviceModel>>
|
||||
public partial class Index : Disco.Services.Web.WebViewPage<IEnumerable<Disco.Web.Areas.Public.Models.HeldDevices.HeldDeviceModel>>
|
||||
{
|
||||
public Index()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
@@ -28,12 +28,14 @@ namespace Disco.Web.Areas.Public.Views.HeldDevices
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Public/Views/HeldDevices/Noticeboard.cshtml")]
|
||||
public partial class Noticeboard : System.Web.Mvc.WebViewPage<dynamic>
|
||||
public partial class Noticeboard : Disco.Services.Web.WebViewPage<dynamic>
|
||||
{
|
||||
public Noticeboard()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
@@ -28,12 +28,14 @@ namespace Disco.Web.Areas.Public.Views.Public
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Public/Views/Public/Credits.cshtml")]
|
||||
public partial class Credits : System.Web.Mvc.WebViewPage<dynamic>
|
||||
public partial class Credits : Disco.Services.Web.WebViewPage<dynamic>
|
||||
{
|
||||
public Credits()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
@@ -28,12 +28,14 @@ namespace Disco.Web.Areas.Public.Views.Public
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Public/Views/Public/Index.cshtml")]
|
||||
public partial class Index : System.Web.Mvc.WebViewPage<dynamic>
|
||||
public partial class Index : Disco.Services.Web.WebViewPage<dynamic>
|
||||
{
|
||||
public Index()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
@@ -28,12 +28,14 @@ namespace Disco.Web.Areas.Public.Views.Public
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Public/Views/Public/Licence.cshtml")]
|
||||
public partial class Licence : System.Web.Mvc.WebViewPage<dynamic>
|
||||
public partial class Licence : Disco.Services.Web.WebViewPage<dynamic>
|
||||
{
|
||||
public Licence()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
@@ -28,12 +28,14 @@ namespace Disco.Web.Areas.Public.Views.Shared
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Public/Views/Shared/_Layout.cshtml")]
|
||||
public partial class Layout : System.Web.Mvc.WebViewPage<dynamic>
|
||||
public partial class Layout : Disco.Services.Web.WebViewPage<dynamic>
|
||||
{
|
||||
public Layout()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
@@ -28,12 +28,14 @@ namespace Disco.Web.Areas.Public.Views.UserHeldDevices
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Public/Views/UserHeldDevices/Index.cshtml")]
|
||||
public partial class Index : System.Web.Mvc.WebViewPage<IEnumerable<Disco.Web.Areas.Public.Models.UserHeldDevices.UserHeldDeviceModel>>
|
||||
public partial class Index : Disco.Services.Web.WebViewPage<IEnumerable<Disco.Web.Areas.Public.Models.UserHeldDevices.UserHeldDeviceModel>>
|
||||
{
|
||||
public Index()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
@@ -28,12 +28,14 @@ namespace Disco.Web.Areas.Public.Views.UserHeldDevices
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Public/Views/UserHeldDevices/Noticeboard.cshtml")]
|
||||
public partial class Noticeboard : System.Web.Mvc.WebViewPage<dynamic>
|
||||
public partial class Noticeboard : Disco.Services.Web.WebViewPage<dynamic>
|
||||
{
|
||||
public Noticeboard()
|
||||
{
|
||||
|
||||
@@ -10,10 +10,12 @@
|
||||
|
||||
<system.web.webPages.razor>
|
||||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
<pages pageBaseType="System.Web.Mvc.WebViewPage">
|
||||
<pages pageBaseType="Disco.Services.Web.WebViewPage">
|
||||
<namespaces>
|
||||
<add namespace="Disco.Models.Repository" />
|
||||
<add namespace="Disco.BI.Extensions" />
|
||||
<add namespace="Disco.Models.Repository" />
|
||||
<add namespace="Disco.Services.Authorization" />
|
||||
<add namespace="Disco.Services.Web" />
|
||||
<add namespace="Disco.Web" />
|
||||
<add namespace="Disco.Web.Extensions" />
|
||||
<add namespace="System.Web.Mvc" />
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
@@ -28,6 +28,8 @@ namespace Disco.Web.Areas.Public.Views
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user