From 37810656fd8eb0083c132ff82452779f7d46c24d Mon Sep 17 00:00:00 2001 From: Gary Sharp Date: Mon, 2 Sep 2013 18:37:30 +1000 Subject: [PATCH] Fix #12: Update users when logging warranty Job User is updated when available. --- Disco.Web/Models/Job/LogWarrantyModel.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Disco.Web/Models/Job/LogWarrantyModel.cs b/Disco.Web/Models/Job/LogWarrantyModel.cs index f4813b06..56bccd6d 100644 --- a/Disco.Web/Models/Job/LogWarrantyModel.cs +++ b/Disco.Web/Models/Job/LogWarrantyModel.cs @@ -62,6 +62,17 @@ namespace Disco.Web.Models.Job dbContext.Configuration.LazyLoadingEnabled = true; if (Job == null) { + // Update Job User's Details [#12] + string jobUserId = dbContext.Jobs.Where(j => j.Id == JobId).Select(j => j.UserId).FirstOrDefault(); + if (jobUserId != null) + { + // Ignore update errors (Most commonly when the User Id no longer exists in AD) + try + { + Disco.BI.UserBI.UserCache.GetUser(jobUserId, dbContext, true); + } catch (Exception) {} + } + Job = (from j in dbContext.Jobs.Include("Device.DeviceModel").Include("JobMetaWarranty").Include("JobSubTypes") where (j.Id == JobId) select j).FirstOrDefault(); @@ -71,7 +82,8 @@ namespace Disco.Web.Models.Job } } - this.TechUser = DiscoApplication.CurrentUser; + // Update TechUser's Details [#12] + this.TechUser = Disco.BI.UserBI.UserCache.GetUser(DiscoApplication.CurrentUser.Id, dbContext, true); WarrantyProviders = Plugins.GetPluginFeatures(typeof(WarrantyProviderFeature));