Ejemplo n.º 1
0
        /// <summary>
        /// Create a new instance of an AccessRequest for a default user.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Entity.AccessRequest CreateAccessRequest(int id)
        {
            var user = EntityHelper.CreateUser("test");

            return(CreateAccessRequest(id, user));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a default list of Workflow.
        /// </summary>
        /// <returns></returns>
        public static List <Entity.Workflow> CreateDefaultWorkflowsWithStatus()
        {
            var status    = EntityHelper.CreateDefaultProjectStatus();
            var workflows = CreateDefaultWorkflows();

            // Add project status to workflow and transitions.
            var draft    = workflows.First(w => w.Code == "SUBMIT-DISPOSAL");
            var assess   = workflows.First(w => w.Code == "ASSESS-DISPOSAL");
            var exempt   = workflows.First(w => w.Code == "ASSESS-EXEMPTION");
            var asExempt = workflows.First(w => w.Code == "ASSESS-EX-DISPOSAL");
            var erp      = workflows.First(w => w.Code == "ERP");
            var spl      = workflows.First(w => w.Code == "SPL");

            // SUBMIT-DISPOSE
            var start     = draft.AddStatus(status.First(s => s.Code == "DR"), 0);
            var select    = start.AddTransition("Select Properties", draft, status.First(s => s.Code == "DR-P"), 1);
            var update    = select.AddTransition("Update Information", draft, status.First(s => s.Code == "DR-I"), 2);
            var docs      = update.AddTransition("Provide Documentation", draft, status.First(s => s.Code == "DR-D"), 3);
            var approval  = docs.AddTransition("Gain Approval", draft, status.First(s => s.Code == "DR-A"), 4);
            var preSubmit = approval.AddTransition("Review", draft, status.First(s => s.Code == "DR-RE"), 5);

            // ASSESS-DISPOSE
            var submitted = assess.AddStatus(status.First(s => s.Code == "AS-I"), 1);

            preSubmit.AddTransition("Submit", submitted);
            var rDocs      = submitted.AddTransition("Review Documentation", assess, status.First(s => s.Code == "AS-D"), 2);
            var rAppraisal = rDocs.AddTransition("Review Appraisal", assess, status.First(s => s.Code == "AS-AP"), 3);
            var rFnc       = rAppraisal.AddTransition("Begin First Nation Consultation", assess, status.First(s => s.Code == "AS-FNC"), 4);

            rFnc.AddTransition("Deny", assess, status.First(s => s.Code == "DE"), 5);

            // ASSESS-EXEMPTION
            var subExe = exempt.AddStatus(status.First(s => s.Code == "AS-EXE"), 1);

            preSubmit.AddTransition("Submit with Exemption", subExe);
            var rDocsExe      = subExe.AddTransition("Review Documentation", exempt, status.First(s => s.Code == "AS-D"), 2);
            var rApprasialExe = rDocsExe.AddTransition("Review Appraisal", exempt, status.First(s => s.Code == "AS-AP"), 3);
            var rFncExe       = rApprasialExe.AddTransition("Begin First Nation Consultation", exempt, status.First(s => s.Code == "AS-FNC"), 4);
            var exReview      = rFncExe.AddTransition("Review Exemption", exempt, status.First(s => s.Code == "AS-EXP"), 5);

            exReview.AddTransition("Deny", exempt, status.First(s => s.Code == "DE"), 6);

            // ASSESS-EX-DISPOSAL
            var aEx = asExempt.AddStatus(status.First(s => s.Code == "AP-EXE"), 1);

            exReview.AddTransition("Approve Exemption", aEx);
            aEx.AddTransition("Transfer within GRE", asExempt, status.First(s => s.Code == "T-GRE"), 6);
            var aNotSpl = aEx.AddTransition("Approve not included in SPL", asExempt, status.First(s => s.Code == "AP-!SPL"), 7);

            aNotSpl.AddTransition("Dispose Properties", asExempt, status.First(s => s.Code == "DIS"), 9);
            aEx.AddTransition("Cancel Project", asExempt, status.First(s => s.Code == "CA"), 8);

            // ERP
            var aErp = erp.AddStatus(status.First(s => s.Code == "AP-ERP"), 1);

            rFnc.AddTransition("Approve for ERP", aErp);
            var erpBegin  = aErp.AddTransition("Begin ERP", erp, status.First(s => s.Code == "ERP-ON"), 2);
            var erpOnHold = erpBegin.AddTransition("Place on Hold", erp, status.First(s => s.Code == "ERP-OH"), 3);

            erpBegin.AddTransition("Transfer within GRE", erp, status.First(s => s.Code == "T-GRE"), 4);
            erpOnHold.AddTransition("Transfer within GRE", erp, status.First(s => s.Code == "T-GRE"), 4);
            var aErpNotSpl = erpBegin.AddTransition("Approve not included in SPL", erp, status.First(s => s.Code == "AP-!SPL"), 5);

            aErpNotSpl.AddTransition("Dispose Properties", erp, status.First(s => s.Code == "DIS"), 7);
            var aErpNotSplOh = erpOnHold.AddTransition("Approve not included in SPL", erp, status.First(s => s.Code == "AP-!SPL"), 5);

            aErpNotSplOh.AddTransition("Dispose Properties", erp, status.First(s => s.Code == "DIS"), 7);
            erpBegin.AddTransition("Cancel Project", erp, status.First(s => s.Code == "CA"), 6);
            erpOnHold.AddTransition("Cancel Project", erp, status.First(s => s.Code == "CA"), 6);

            // SPL
            var aSpl = spl.AddStatus(status.First(s => s.Code == "AP-SPL"), 1);

            exReview.AddTransition("Approve for SPL", aSpl);
            erpBegin.AddTransition("Approve for SPL", aSpl);
            erpOnHold.AddTransition("Approve for SPL", aSpl);
            var SplPm = aSpl.AddTransition("Begin Pre-Marketing", spl, status.First(s => s.Code == "SPL-PM"), 2);
            var SplM  = SplPm.AddTransition("Begin Marketing", spl, status.First(s => s.Code == "SPL-M"), 3);
            var splContractInPlace = SplM.AddTransition("Contract in Place - Conditional", spl, status.First(s => s.Code == "SPL-CIP-C"), 4);

            splContractInPlace.AddTransition("Dispose Properties", spl, status.First(s => s.Code == "DIS"), 5);
            splContractInPlace.AddTransition("Cancel Project", spl, status.First(s => s.Code == "CA"), 6);

            return(workflows);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a new instance of a Project.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="agencyId"></param>
        /// <returns></returns>
        public static Entity.Project CreateProject(int id, int agencyId)
        {
            var agency = EntityHelper.CreateAgency(agencyId);

            return(CreateProject(id, agency));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a new instance of a Project.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="id"></param>
        /// <param name="agency"></param>
        /// <returns></returns>
        public static Entity.Project CreateProject(this PimsContext context, int id, int agencyId)
        {
            var agency = context.Agencies.Find(agencyId) ?? EntityHelper.CreateAgency(agencyId);

            return(context.CreateProject(id, agency));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a default list of Organization.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="identifierType"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public static List <Entity.PimsOrganization> CreateDefaultOrganizations(Entity.PimsOrganizationType type = null, Entity.PimsOrgIdentifierType identifierType = null, Entity.PimsAddress address = null)
        {
            type ??= EntityHelper.CreateOrganizationType("Type 1");
            identifierType ??= EntityHelper.CreateOrganizationIdentifierType("Identifier 1");
            return(new List <Entity.PimsOrganization>()
            {
                // Parent organizations
                new Entity.PimsOrganization("Ministry of Advanced Education, Skills & Training", type, identifierType, address ?? EntityHelper.CreateAddress(1000))
                {
                    Id = 1, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Citizens Service", type, identifierType, address ?? EntityHelper.CreateAddress(1002))
                {
                    Id = 2, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Corporate Services for the Natural Resources Sector", type, identifierType, address ?? EntityHelper.CreateAddress(1003))
                {
                    Id = 3, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Education", type, identifierType, address ?? EntityHelper.CreateAddress(1004))
                {
                    Id = 4, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Finance", type, identifierType, address ?? EntityHelper.CreateAddress(1005))
                {
                    Id = 5, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Forests, Lands, Natural Resources", type, identifierType, address ?? EntityHelper.CreateAddress(1006))
                {
                    Id = 6
                },
                new Entity.PimsOrganization("Ministry of Health", type, identifierType, address ?? EntityHelper.CreateAddress(1007))
                {
                    Id = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Municipal Affairs & Housing", type, identifierType, address ?? EntityHelper.CreateAddress(1008))
                {
                    Id = 8, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Transportation and Infrastructure", type, identifierType, address ?? EntityHelper.CreateAddress(1009))
                {
                    Id = 9, ConcurrencyControlNumber = 1
                },

                // Sub-organizations
                new Entity.PimsOrganization("Ministry Lead", type, identifierType, address ?? EntityHelper.CreateAddress(1010))
                {
                    Id = 10, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Acting Deputy Minister", type, identifierType, address ?? EntityHelper.CreateAddress(1011))
                {
                    Id = 11, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Executive Director", type, identifierType, address ?? EntityHelper.CreateAddress(1012))
                {
                    Id = 12, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Fraser Health Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1013))
                {
                    Id = 13, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Interior Health Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1014))
                {
                    Id = 14, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Northern Health Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1015))
                {
                    Id = 15, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Provincial Health Services Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1016))
                {
                    Id = 16, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Vancouver Coastal Health Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1017))
                {
                    Id = 17, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Vancouver Island Health Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1018))
                {
                    Id = 18, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                }
            });
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a new instance of a Building.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="parcel"></param>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="lat"></param>
        /// <param name="lng"></param>
        /// <param name="agency"></param>
        /// <returns></returns>
        public static Entity.Building CreateBuilding(this PimsContext context, Entity.Parcel parcel, int id, string projectNumber = null, string name = null, int lat = 0, int lng = 0, Entity.Agency agency = null)
        {
            name ??= $"l{id}";
            agency ??= parcel?.Agency ?? context.Agencies.FirstOrDefault() ?? EntityHelper.CreateAgency(id);
            var address = (parcel == null ? EntityHelper.CreateAddress(context, id, "1234 Street", null, "V9C9C9") :
                           EntityHelper.CreateAddress(id, parcel.Address.Address1, parcel.Address.Address2, parcel.Address.AdministrativeArea, parcel.Address.Province, parcel.Address.Postal));
            var predominateUse   = context.BuildingPredominateUses.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingPredominateUse("use");;
            var constructionType = context.BuildingConstructionTypes.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingConstructionType("type");
            var occupantType     = context.BuildingOccupantTypes.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingOccupantType("occupant");
            var classification   = context.PropertyClassifications.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreatePropertyClassification("classification");

            var building = new Entity.Building(parcel, lat, lng)
            {
                Id                         = id,
                Name                       = name,
                ProjectNumbers             = projectNumber,
                AgencyId                   = agency.Id,
                Agency                     = agency,
                AddressId                  = address.Id,
                Address                    = address,
                Classification             = classification,
                ClassificationId           = classification.Id,
                Description                = $"description-{id}",
                BuildingPredominateUse     = predominateUse,
                BuildingPredominateUseId   = predominateUse.Id,
                BuildingConstructionType   = constructionType,
                BuildingConstructionTypeId = constructionType.Id,
                BuildingOccupantType       = occupantType,
                BuildingOccupantTypeId     = occupantType.Id,
                CreatedById                = Guid.NewGuid(),
                CreatedOn                  = DateTime.UtcNow,
                UpdatedById                = Guid.NewGuid(),
                UpdatedOn                  = DateTime.UtcNow,
                RowVersion                 = new byte[] { 12, 13, 14 }
            };

            if (parcel != null)
            {
                var parcelBuilding = new Entity.ParcelBuilding(parcel, building);
            }
            context.Buildings.Add(building);
            return(building);
        }