예제 #1
0
        /// <summary>
        /// Create a new instance of a Project.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="agency"></param>
        /// <param name="tierLevel"></param>
        /// <param name="workflowStatus"></param>
        /// <returns></returns>
        public static Entity.Project CreateProject(int id, Entity.Agency agency = null, Entity.TierLevel tierLevel = null, Entity.WorkflowProjectStatus workflowStatus = null, Entity.ProjectRisk risk = null)
        {
            agency ??= EntityHelper.CreateAgency(id);
            tierLevel ??= EntityHelper.CreateTierLevel(id, "tierLevel");
            risk ??= EntityHelper.CreateProjectRisk(id, "risk", "risk", 1);
            var status   = workflowStatus?.Status ?? EntityHelper.CreateProjectStatus("Draft", "DR");
            var workflow = workflowStatus?.Workflow ?? EntityHelper.CreateWorkflow(id, "Submit", "SUBMIT-DISPOSAL", new[] { status });

            var user = CreateUser(Guid.NewGuid(), "project tester", "asasa", "asasa", null, agency);

            return(new Entity.Project($"SPP-{id:00000}", $"test-{id}", tierLevel)
            {
                ReportedFiscalYear = DateTime.UtcNow.GetFiscalYear(),
                ActualFiscalYear = DateTime.UtcNow.GetFiscalYear(),
                Risk = risk,
                RiskId = risk.Id,
                Agency = agency,
                AgencyId = agency.Id,
                Workflow = workflow,
                WorkflowId = workflow?.Id,
                Status = status,
                StatusId = status.Id,
                Description = $"description-{id}",
                CreatedBy = user,
                CreatedById = user.Id,
                CreatedOn = DateTime.UtcNow,
                UpdatedById = user.Id,
                UpdatedBy = user,
                PublicNote = $"publicNote-{id}",
                PrivateNote = $"privateNote-{id}",
                UpdatedOn = DateTime.UtcNow,
                Metadata = "{offerAmount: 123}",
                RowVersion = new byte[] { 12, 13, 14 }
            });
        }
예제 #2
0
        /// <summary>
        /// Create a new instance of a Project.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="id"></param>
        /// <param name="agency"></param>
        /// <param name="workflowStatus"></param>
        /// <param name="risk"></param>
        /// <returns></returns>
        public static Entity.Project CreateProject(this PimsContext context, int id, Entity.Agency agency = null, Entity.WorkflowProjectStatus workflowStatus = null, Entity.ProjectRisk risk = null)
        {
            agency ??= context.Agencies.OrderBy(a => a.Id).FirstOrDefault() ?? EntityHelper.CreateAgency(1);
            risk ??= context.ProjectRisks.FirstOrDefault() ?? EntityHelper.CreateProjectRisk(1, "risk", "risk", 1);
            workflowStatus ??= context.WorkflowProjectStatus.FirstOrDefault(ws => ws.WorkflowId == 1 && ws.StatusId == 1);
            if (workflowStatus == null)
            {
                var status   = workflowStatus?.Status ?? EntityHelper.CreateProjectStatus("Draft", "DR");
                var workflow = workflowStatus?.Workflow ?? EntityHelper.CreateWorkflow(id, "Submit", "SUBMIT-DISPOSAL", new[] { status });
                workflowStatus ??= workflow.Status.First();
            }

            var tierLevel = context.TierLevels.FirstOrDefault(s => s.Id == 1) ?? EntityHelper.CreateTierLevel("tierLevel");

            var project = EntityHelper.CreateProject(id, agency, tierLevel, workflowStatus, risk);

            context.Projects.Add(project);
            return(project);
        }
예제 #3
0
        /// <summary>
        /// Create a new List with new instances of Projects.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="startId"></param>
        /// <param name="count"></param>
        /// <param name="agency"></param>
        /// <param name="workflowStatus"></param>
        /// <param name="risk"></param>
        /// <returns></returns>
        public static List <Entity.Project> CreateProjects(this PimsContext context, int startId, int count, Entity.Agency agency = null, Entity.WorkflowProjectStatus workflowStatus = null, Entity.ProjectRisk risk = null)
        {
            agency ??= context.Agencies.FirstOrDefault(a => a.Id == 1) ?? EntityHelper.CreateAgency(startId);
            risk ??= context.ProjectRisks.FirstOrDefault() ?? EntityHelper.CreateProjectRisk(1, "risk", "risk", 1);
            workflowStatus ??= context.WorkflowProjectStatus.FirstOrDefault(ws => ws.WorkflowId == 1 && ws.StatusId == 1);
            if (workflowStatus == null)
            {
                var status   = workflowStatus?.Status ?? EntityHelper.CreateProjectStatus("Draft", "DR");
                var workflow = workflowStatus?.Workflow ?? EntityHelper.CreateWorkflow(startId, "Submit", "SUBMIT-DISPOSAL", new[] { status });
                workflowStatus ??= workflow.Status.First();
            }

            var projects = new List <Entity.Project>(count);

            for (var i = startId; i < (startId + count); i++)
            {
                projects.Add(context.CreateProject(i, agency, workflowStatus, risk));
            }
            return(projects);
        }