void addApplicant()
        {
            PhoneCodeModel hm = new PhoneCodeModel { phoneCodeDescription = "Home Phone", phoneCode = "AA", lastModifiedDate = DateTime.Now };
            PhoneCodeModel cm = new PhoneCodeModel { phoneCodeDescription = "Cell Phone", phoneCode = "BB", lastModifiedDate = DateTime.Now };

            List<PhoneModel> phones = new List<PhoneModel>();
            PhoneModel p1 = new PhoneModel();
            p1.createDate = DateTime.Now;
            p1.lastModifiedDate = DateTime.Now;
            p1.phoneNumber = 1231231233;
            p1.phoneCd = hm.phoneCode;
            phones.Add(p1);

            PhoneModel p2 = new PhoneModel();
            p2.createDate = DateTime.Now;
            p2.lastModifiedDate = DateTime.Now;
            p2.phoneNumber = 9999999999;
            p2.phoneCd = cm.phoneCode;
            phones.Add(p2);

            ApplicantModel a1 = new ApplicantModel();
            a1.applicantId = 1;
            a1.firstName = "Wes";
            a1.lastName = "Reisz";
            a1.middleInitial = "T";
            a1.ssn = "111111111";
            a1.suffix = ""; //this should default if nothing
            a1.phones = phones.ToArray<PhoneModel>();

            //IService service = new PhoneService();
            //service.addOrUpdatePhone(a1);
        }
        //
        // GET: /Phone/Create
        public ActionResult Create()
        {
            IService service = new PhoneService();
            PhoneModel phone = new PhoneModel();

            //Figure out how to create the dropdown list for the page
            //http://blinkingcaret.wordpress.com/2012/08/11/using-html-dropdownlistfor/

            ViewBag.phoneCd = new SelectList(service.getPhoneCds(), "phoneCd", "phoneCodeDescription", phone.phoneCd);
            return View(phone);
        }
        public PhoneModel getPhoneById(decimal phoneId)
        {
            PhoneRepo phoneRepo = new PhoneRepo();
            Phone phoneData = phoneRepo.getById(new Phone{PHONE_ID=phoneId});
            PhoneModel phoneModel = new PhoneModel();
            phoneModel.phoneId = phoneData.PHONE_ID;
            phoneModel.applicantId = phoneData.APPLICANT_ID;
            phoneModel.createDate = phoneData.CREATE_DT;
            phoneModel.lastModifiedDate = phoneData.MOD_DT;
            phoneModel.phoneCd = phoneData.PHONE_CD;
            phoneModel.phoneNumber = phoneData.PHONE_TX;

            return phoneModel;
        }
        public void addOrUpdatePhone(PhoneModel phone)
        {
            PhoneRepo repo = new PhoneRepo();
            Phone p = repo.getById(new Phone {PHONE_ID=phone.phoneId });
            if (p!=null){
                repo.update(p);
            }else{
                Phone p1 = new Phone();
                p1.APPLICANT_ID = phone.applicantId;
                p1.CREATE_DT = DateTime.Now;
                p1.MOD_DT = DateTime.Now;
                p1.PHONE_CD=phone.phoneCd;
                p1.PHONE_TX=1231231234;

                repo.add(p1);
            }

            repo = null;
        }
        public ICollection<PhoneModel> listPhonesByUser(decimal userId)
        {
            PhoneRepo phoneRepo = new PhoneRepo();
            IEnumerable<Phone> phones = phoneRepo.query(p => p.APPLICANT_ID == userId);

            ICollection<PhoneModel> phoneModels = new List<PhoneModel>();
            PhoneModel phoneModel = null;
            foreach (Phone p1 in phones)
            {
                phoneModel = new PhoneModel();
                phoneModel.phoneCd = p1.PHONE_CD;
                phoneModel.phoneNumber = p1.PHONE_TX;
                phoneModel.lastModifiedDate = p1.MOD_DT;
                phoneModel.applicantId = userId;
                phoneModel.createDate = p1.CREATE_DT;
                phoneModel.phoneId = p1.PHONE_ID;

                phoneModels.Add(phoneModel);
            }
            phoneRepo = null;
            return phoneModels;
        }
        public ICollection<PhoneModel> listPhones()
        {
            PhoneRepo phoneRepo = new PhoneRepo();
            IEnumerable<Phone> phones = phoneRepo.getAll();

            ICollection<PhoneModel> phoneModels = new List<PhoneModel>();
            PhoneModel phoneModel = null;
            foreach (Phone phoneData in phones)
            {
                phoneModel = new PhoneModel();
                phoneModel.phoneCd = phoneData.PHONE_CD;
                phoneModel.phoneNumber = phoneData.PHONE_TX;
                phoneModel.lastModifiedDate = phoneData.MOD_DT;
                phoneModel.applicantId = phoneData.APPLICANT_ID;
                phoneModel.createDate = phoneData.CREATE_DT;
                phoneModel.phoneId = phoneData.PHONE_ID;

                phoneModels.Add(phoneModel);
            }
            phoneRepo = null;
            return phoneModels;
        }
 public void removePhone(PhoneModel phone)
 {
     PhoneRepo repo = new PhoneRepo();
        repo.remove(
        repo.getById(new Phone { PHONE_ID = phone.phoneId })
        );
        repo = null;
 }