예제 #1
0
 /// <summary>
 /// Create a new ProgramInstanceSponsor object.
 /// </summary>
 /// <param name="programID">Initial value of the ProgramID property.</param>
 /// <param name="timePeriodID">Initial value of the TimePeriodID property.</param>
 /// <param name="sponsorID">Initial value of the SponsorID property.</param>
 public static ProgramInstanceSponsor CreateProgramInstanceSponsor(global::System.Int32 programID, global::System.Int16 timePeriodID, global::System.Int32 sponsorID)
 {
     ProgramInstanceSponsor programInstanceSponsor = new ProgramInstanceSponsor();
     programInstanceSponsor.ProgramID = programID;
     programInstanceSponsor.TimePeriodID = timePeriodID;
     programInstanceSponsor.SponsorID = sponsorID;
     return programInstanceSponsor;
 }
예제 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ProgramInstanceSponsors EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProgramInstanceSponsors(ProgramInstanceSponsor programInstanceSponsor)
 {
     base.AddObject("ProgramInstanceSponsors", programInstanceSponsor);
 }
예제 #3
0
        public int RtpCreatePlan(RtpCreatePlanRequest request)
        {
            using (var db = new Models.TRIPSEntities())
            {
                // create a time period for the plan
                var tp = new Models.TimePeriod()
                {
                    TimePeriodTypeID = (int)Enums.TimePeriodType.PlanYear,
                    TimePeriod1 = request.PlanName
                };
                db.TimePeriods.AddObject(tp);

                // create pieces of the plan, with a status of Pending
                var pi = new Models.ProgramInstance()
                {
                    StatusId = (int)Enums.RtpTimePeriodStatus.Pending,
                    ProgramID = 2,
                    TimePeriod = tp
                };
                db.ProgramInstances.AddObject(pi);

                var rtpi = new Models.RTPProgramInstance()
                {
                    ProgramInstance = pi,
                    TimePeriod = tp
                };
                db.RTPProgramInstances.AddObject(rtpi);

                db.SaveChanges();
                Logger.Debug("created RTP Program Instance " + rtpi.RTPProgramID.ToString() + ", " + rtpi.TimePeriodID.ToString());

                // we had to save the changes to get IDs for the created objects,
                // since the TimePeriodID is part of a compound key.

                // TODO: get active plan
                int activePlan = 78;

                // copy the sponsors from the current plan
                foreach (var sponsor in db.RTPProgramInstanceSponsors.Where(r => r.TimePeriodID == activePlan))
                {
                    // first create a base ProgramInstanceSponsor
                    var pis = new Models.ProgramInstanceSponsor()
                    {
                        ProgramID = sponsor.RTPProgramID,
                        SponsorID = sponsor.SponsorID,
                        TimePeriodID = tp.TimePeriodID
                    };
                    db.ProgramInstanceSponsors.AddObject(pis);

                    var copy = new Models.RTPProgramInstanceSponsor()
                    {
                        EmailDate = sponsor.EmailDate,
                        FormPrintedDate = sponsor.FormPrintedDate,
                        ReadyDate = sponsor.ReadyDate,
                        RTPProgramID = sponsor.RTPProgramID,
                        SponsorID = sponsor.SponsorID,
                        TimePeriodID = tp.TimePeriodID
                    };
                    db.RTPProgramInstanceSponsors.AddObject(copy);
                }

                // create a pending cycle
                var mcycle = new Models.Cycle()
                {
                    cycle1 = request.CycleName,
                    Description = request.CycleDescription,
                    statusId = (int)Enums.RTPCycleStatus.Pending,
                    priorCycleId = null
                };
                db.Cycles.AddObject(mcycle);

                var mtpc = new Models.TimePeriodCycle()
                {
                    Cycle = mcycle,
                    TimePeriodId = tp.TimePeriodID,
                    ListOrder = 1
                };
                db.TimePeriodCycles.AddObject(mtpc);
                db.SaveChanges();
                Logger.Debug("copied sponsors from RTP Plan " + activePlan.ToString());
                Logger.Debug("created RTP Plan Cycle " + mcycle.id.ToString());

                return tp.TimePeriodID;
            }
        }