Esempio n. 1
0
 /// <summary>
 /// Create a new RTPProgramInstance object.
 /// </summary>
 /// <param name="rTPProgramID">Initial value of the RTPProgramID property.</param>
 /// <param name="timePeriodID">Initial value of the TimePeriodID property.</param>
 public static RTPProgramInstance CreateRTPProgramInstance(global::System.Int32 rTPProgramID, global::System.Int16 timePeriodID)
 {
     RTPProgramInstance rTPProgramInstance = new RTPProgramInstance();
     rTPProgramInstance.RTPProgramID = rTPProgramID;
     rTPProgramInstance.TimePeriodID = timePeriodID;
     return rTPProgramInstance;
 }
Esempio n. 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the RTPProgramInstances EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRTPProgramInstances(RTPProgramInstance rTPProgramInstance)
 {
     base.AddObject("RTPProgramInstances", rTPProgramInstance);
 }
Esempio n. 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;
            }
        }