/// <summary> /// Reloads this instance from the persistence storage medium. /// </summary> /// <returns>true if this instance was reloaded successfully; otherwise, false.</returns> public bool Reload() { CmoCategory current = CmoProviders.DataProvider.GetCmoCategory(_id); if (current != null) { this.Description = current.Description; this.MessageTemplateBody = current.MessageTemplateBody; this.MessageTemplateTitle = current.MessageTemplateTitle; this.Name = current.Name; return(true); } return(false); }
/// <summary> /// Gets a collection of IDs for all post election audit reports for a specific candidate and election cycle. /// </summary> /// <param name="candidateID">The CFIS ID of the reviewed candidate.</param> /// <param name="electionCycle">The election cycle of the reviews.</param> /// <returns>A collection of unique IDs for all post election audit report CMO messages found.</returns> public Dictionary <AuditReportType, string> GetAuditReportMessageIDs(string candidateID, string electionCycle) { using (Data.CmoEntities context = new Data.CmoEntities()) { var categories = new List <byte> { CmoCategory.IdrCategoryID, CmoCategory.IdrInadequateCategoryID, CmoCategory.IdrAdditionalInadequateCategoryID, CmoCategory.DarCategoryID, CmoCategory.DarInadequateCategoryID, CmoCategory.DarAdditionalInadequateCategoryID, CmoCategory.FarCategoryID }; var messages = from m in context.CmoMessages join c in context.CmoCategories on m.CmoCategory.CategoryId equals c.CategoryId where m.CandidateId == candidateID && m.ElectionCycle == electionCycle && m.PostDate.HasValue && categories.Contains(m.CmoCategory.CategoryId) group m by m.CmoCategory.CategoryId into mgroup select new { CategoryID = mgroup.Key, MessageID = mgroup.Max(m => m.MessageId) }; return((from m in messages.AsEnumerable().Select(m => new { AuditReportType = CmoCategory.ToAuditReportType(m.CategoryID), m.MessageID }) where m.AuditReportType.HasValue select m).ToDictionary(m => m.AuditReportType.Value, m => CmoMessage.ToUniqueID(candidateID, m.MessageID))); } }