Disco.Services.Documents.ManagedGroups.DocumentTemplateDevicesManagedGroup.JobsContainAttachment C# (CSharp) Method

JobsContainAttachment() private method

private JobsContainAttachment ( DiscoDataContext Database, int JobId, string &DeviceAccountId, string &DeviceSerialNumber ) : bool
Database Disco.Data.Repository.DiscoDataContext
JobId int
DeviceAccountId string
DeviceSerialNumber string
return bool
        private bool JobsContainAttachment(DiscoDataContext Database, int JobId, out string DeviceAccountId, out string DeviceSerialNumber)
        {
            Tuple<string, string, bool> result;

            if (Configuration.FilterBeginDate.HasValue)
            {
                result = Database.Jobs
                    .Where(j => j.Id == JobId && j.Device.DeviceDomainId != null)
                    .Select(j => new Tuple<string, string, bool>(
                        j.Device.DeviceDomainId,
                        j.Device.SerialNumber,
                        j.Device.Jobs.Any(dj => dj.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))))
                    .FirstOrDefault();
            }
            else
            {
                result = Database.Jobs
                    .Where(j => j.Id == JobId && j.Device.DeviceDomainId != null)
                    .Select(j => new Tuple<string, string, bool>(
                        j.Device.DeviceDomainId,
                        j.Device.SerialNumber,
                        j.Device.Jobs.Any(dj => dj.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId))))
                    .FirstOrDefault();
            }


            if (result == null)
            {
                DeviceAccountId = null;
                DeviceSerialNumber = null;
                return false;
            }
            else
            {
                if (ActiveDirectory.IsValidDomainAccountId(result.Item1))
                {
                    DeviceAccountId = result.Item1 + "$";
                    DeviceSerialNumber = result.Item2;
                    return result.Item3;
                }
                else
                {
                    DeviceAccountId = result.Item1 + "$";
                    DeviceSerialNumber = result.Item2;
                    return false;
                }
            }
        }