/// <summary>
        /// Create an enrollee object matching a unifying format and store it
        /// into the database. Unifying format means no extra characters in
        /// ssn, homephone, or mobilephone
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="ssn"></param>
        /// <param name="mailingAddr"></param>
        /// <param name="billingAddr"></param>
        /// <param name="pin"></param>
        /// <param name="contactInfo"></param>
        public void CreatePrimaryEnrollee(
            string firstName,
            string lastName,
            string ssn,
            string mailingAddr,
            string billingAddr,
            string pin,
            Contact contactInfo)
        {
            // the ssn can come in a variety formats and I need to make sure
            // they all just end up in the format NNNNNNNNN
            var transformedSSN    = ssn.Replace(" ", "").Replace("-", "");
            var transformedHome   = TransformPhone(contactInfo.homePhone);
            var transformedMobile = TransformPhone(contactInfo.mobilePhone);

            this.PrimaryEnrollee = new PrimaryEnrollee(pin)
            {
                BillingAddr = billingAddr,
                Email       = contactInfo.email,
                FirstName   = firstName,
                HomePhone   = transformedHome,
                LastName    = lastName,
                MailingAddr = mailingAddr,
                MobilePhone = transformedMobile,
                SSN         = transformedSSN
            };
            insertId = Mgr.SaveEnrollee(this.PrimaryEnrollee);
        }
        /// <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);
        }
Exemple #3
0
        public void CheckEnrolleeTest()
        {
            DbMgr Mgr;

            Mgr = DbMgr.Instance;
            PrimaryEnrollee e = new PrimaryEnrollee("0");

            e.FirstName = "A";
            e.LastName  = "B";
            e.SSN       = "123456778";

            Mgr.SaveEnrollee(e);

            var  bill    = new BillController();
            bool notTrue = bill.CheckEnrollee("A");
            bool soTrue  = bill.CheckEnrollee("A B");

            Assert.IsFalse(notTrue);
            Assert.IsTrue(soTrue);
        }