Example #1
0
        /// <summary>
        /// Exports the certificate.
        /// </summary>
        /// <param name="certificate">The certificate.</param>
        private static SerializableCertificate ExportCertificate(CrtCertificates certificate)
        {
            SerializableCertificate crtCertificate = new SerializableCertificate
            {
                ID = certificate.ID,
                Description = certificate.Description
            };

            // Export prerequesities
            IEnumerable<SerializableCertificatePrerequisite> listOfPrereq = Database.CrtRelationshipsTable
                .Where(x => x.ChildID == certificate.ID && x.ParentLevel != 0)
                .Select(relationship => new SerializableCertificatePrerequisite
                {
                    ID = Database.InvTypesTable[relationship.ParentTypeID].ID,
                    Skill = Database.InvTypesTable[relationship.ParentTypeID].Name,
                    Level = relationship.ParentLevel.ToString(CultureInfo.InvariantCulture),
                    Grade = (CertificateGrade)Enum.ToObject(typeof(CertificateGrade), relationship.Grade),
                });

            //Add prerequisites to certificate
            crtCertificate.Prerequisites.AddRange(listOfPrereq.OrderBy(x => x.Grade));

            // Add recommendations to certificate
            IEnumerable<SerializableCertificateRecommendation> listOfRecommendations = Database.CrtRecommendationsTable.Where(
                x => x.CertificateID == certificate.ID)
                .Select(recommendation => new SerializableCertificateRecommendation
                {
                    ID = recommendation.ShipTypeID,
                    ShipName = Database.InvTypesTable[recommendation.ShipTypeID].Name,
                });

            crtCertificate.Recommendations.AddRange(listOfRecommendations);

            // Add certificate
            return crtCertificate;
        }
Example #2
0
        /// <summary>
        /// Certificates
        /// </summary>
        /// <returns><c>Bag</c> of Certificates</returns>
        internal static Bag<CrtCertificates> Certificates()
        {
            var list = new IndexedList<CrtCertificates>();

            foreach (crtCertificates certificate in Context.crtCertificates)
            {
                var item = new CrtCertificates
                               {
                                   ID = certificate.certificateID,
                                   Description = certificate.description.Clean()
                               };

                if (certificate.categoryID.HasValue)
                    item.CategoryID = certificate.categoryID.Value;

                if (certificate.classID.HasValue)
                    item.ClassID = certificate.classID.Value;

                if (certificate.grade.HasValue)
                    item.Grade = certificate.grade.Value;

                list.Items.Add(item);
            }

            return new Bag<CrtCertificates>(list);
        }
Example #3
0
        /// <summary>
        /// Certificate Certificates.
        /// </summary>
        /// <returns><c>BagCollection</c> of Certificates.</returns>
        private static BagCollection<CrtCertificates> Certificates()
        {
            IndexedCollection<CrtCertificates> collection = new IndexedCollection<CrtCertificates>();

            foreach (crtCertificates certificate in s_context.crtCertificates)
            {
                CrtCertificates item = new CrtCertificates
                {
                    ID = certificate.certificateID,
                    Description = certificate.description
                };

                item.Description = item.Description.Clean();

                if (certificate.groupID.HasValue)
                    item.GroupID = certificate.groupID.Value;

                if (certificate.classID.HasValue)
                    item.ClassID = certificate.classID.Value;

                if (certificate.grade.HasValue)
                    item.Grade = certificate.grade.Value;

                collection.Items.Add(item);
            }

            CertificatesTotalCount = collection.Items.Select(x => x.GroupID).Distinct().Count();

            return collection.ToBag();
        }