Beispiel #1
0
        public ModifyPlanController(int EnrolleeId)
        {
            this.AvailablePlans = Mgr.GetPlanByPrimary(EnrolleeId);

            if (this.AvailablePlans.Count() == 1)
            {
                this.CurrentPlan = this.AvailablePlans.ElementAt(0);
            }
        }
        /// <summary>
        /// Creates a new dependent object and attaches it to the the enrollee
        /// of the primary enrollee pointed to by primaryId
        /// </summary>
        /// <param name="primaryId"></param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="ssn"></param>
        /// <param name="relationship"></param>
        /// <param name="pin"></param>
        /// <param name="contact"></param>
        /// <returns></returns>
        public int CreateDependent(
            int planNum,
            int primaryId,
            string firstName,
            string lastName,
            string ssn,
            string relationship,
            string pin,
            Contact contact
            )
        {
            var enrolleePlan = Mgr.GetPlanByPrimary(primaryId)
                               .Where(e => e.PlanNum == planNum)
                               .SingleOrDefault();
            var dep = new DependentEnrollee(pin)
            {
                Email        = contact.email,
                FirstName    = firstName,
                HomePhone    = contact.homePhone,
                LastName     = lastName,
                MobilePhone  = contact.mobilePhone,
                Relationship = relationship,
                SSN          = ssn
            };

            enrolleePlan.AddDependent(dep);
            //try
            //{
            int insertId = (int)Mgr.SaveEnrollee(dep);

            enrolleePlan.Dependents.Add(insertId);
            Mgr.SaveEnrolleePlan(enrolleePlan);
            //}

            /*catch (SqlException)
             * {
             *  throw new DataException("Enrollee already exists on plan");
             * }*/


            return(enrolleePlan.PlanNum);
        }