public void Test_CreateApplicant()
 {
     ApplicantDAO applicant6 = new ApplicantDAO() { ApplicantID = 6, FirstName = "TestFirst", LastName = "TestLast", Phone = "TestNum", SSN = "TestSSN" };
     applicantService.CreateApplicant(applicant6);
     Assert.AreEqual(applicant6.ApplicantID, 6);
     Assert.IsNotNull(applicantService.GetApplicantByID(6));
 }
        public bool CreateApplicant(ApplicantDAO app)
        {
            Applicant a = new Applicant
            {
                Applicant_ID = app.ApplicantID,
                FirstName = app.FirstName,
                MiddleName = app.MiddleName,
                LastName = app.LastName,
                SSN = app.SSN,
                Gender = app.Gender,
                ApplicantAddress = app.ApplicantAddress,
                Phone = app.Phone,
                NameAlias = app.NameAlias
            };

            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                db.Applicants.InsertOnSubmit(a);

                try
                {
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
                }
            }

            return true;
        }
Esempio n. 3
0
 public bool UpdateApplicant(ApplicantDAO newApp)
 {
     foreach(var applicant in Applicants)
         if (applicant.ApplicantID == newApp.ApplicantID)
         {
             Applicants.Remove(applicant);
             Applicants.Add(newApp);
             return true;
         }
     return false;
 }
        public void Test_UpdateApplicant()
        {
            ApplicantDAO applicant4 = new ApplicantDAO() { ApplicantID = 4, FirstName = "NewFirst4", LastName = "NewLast4", Phone = "4444", SSN = "0005" };

            applicantService.UpdateApplicant(applicant4);
            Assert.AreEqual(applicant4.ApplicantID, 4);
            Assert.AreEqual(applicantService.GetApplicantByID(4).FirstName, "NewFirst4");
            Assert.AreEqual(applicantService.GetApplicantByID(4).LastName, "NewLast4");
            Assert.AreEqual(applicantService.GetApplicantByID(4).SSN, "0005");
            Assert.AreEqual(applicantService.GetApplicantByID(4).Phone, "4444");
        }
Esempio n. 5
0
        internal void SetUp()
        {
            ApplicantDAO applicant1 = new ApplicantDAO() { ApplicantID = 1, FirstName = "First1", LastName = "Last1", Phone = "1111", SSN = "0001" };
            ApplicantDAO applicant2 = new ApplicantDAO() { ApplicantID = 2, FirstName = "First2", LastName = "Last2", Phone = "2222", SSN = "0002" };
            ApplicantDAO applicant3 = new ApplicantDAO() { ApplicantID = 3, FirstName = "First3", LastName = "Last3", Phone = "3333", SSN = "0003" };
            ApplicantDAO applicant4 = new ApplicantDAO() { ApplicantID = 4, FirstName = "First4", LastName = "Last4", Phone = "4444", SSN = "0004" };

            Applicants.Add(applicant1);
            Applicants.Add(applicant2);
            Applicants.Add(applicant3);
            Applicants.Add(applicant4);
        }
Esempio n. 6
0
 private void initializeApplicant( ApplicantDAO applicant, int id, int applicantID, string firstname, string middlename, string lastname, string ssn, string gender, string applicantAddress, string phone, string nameAlias )
 {
     applicant.ID = id;
     applicant.ApplicantID = applicantID;
     applicant.FirstName = firstname;
     applicant.LastName = lastname;
     applicant.MiddleName = middlename;
     applicant.SSN = ssn;
     applicant.Gender = gender;
     applicant.ApplicantAddress = applicantAddress;
     applicant.Phone = phone;
     applicant.NameAlias = nameAlias;
 }
Esempio n. 7
0
 public bool CreateApplicant(ApplicantDAO a)
 {
     Applicants.Add(a);
     return true;
 }
        public bool UpdateApplicant(ApplicantDAO newApp)
        {
            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                Applicant a = db.Applicants.Single(app => app.Applicant_ID == newApp.ApplicantID);
                a.FirstName = newApp.FirstName;
                a.MiddleName = newApp.MiddleName;
                a.LastName = newApp.LastName;
                a.NameAlias = newApp.NameAlias;
                a.Gender = newApp.Gender;
                a.SSN = newApp.SSN;
                a.ApplicantAddress = newApp.ApplicantAddress;
                a.Phone = newApp.Phone;

                try
                {
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
                }
            }

            return true;
        }
        public IList<ApplicantDAO> GetApplicants()
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    IList<Applicant> applicants = (from applicant in db.Applicants select applicant).OrderBy(o => o.Applicant_ID).ToList();
                    List<ApplicantDAO> result = new List<ApplicantDAO>();
                    foreach (var applicant in applicants)
                    {
                        ApplicantDAO temp = new ApplicantDAO
                        {
                            ApplicantID = applicant.Applicant_ID,
                            ID = applicant.Applicant_ID,
                            FirstName = applicant.FirstName,
                            MiddleName = applicant.MiddleName,
                            LastName = applicant.LastName,
                            SSN = applicant.SSN,
                            Gender = applicant.Gender,
                            ApplicantAddress = applicant.ApplicantAddress,
                            Phone = applicant.Phone,
                            NameAlias = applicant.NameAlias
                        };

                        result.Add(temp);
                    }

                    return (result != null ? result : null);
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }
        public ApplicantDAO GetApplicantByID(int id)
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    Applicant applicant = (from a in db.Applicants where a.Applicant_ID == id select a).FirstOrDefault();
                    ApplicantDAO result = new ApplicantDAO
                    {
                        ApplicantID = applicant.Applicant_ID,
                        ID = applicant.Applicant_ID,
                        FirstName = applicant.FirstName,
                        MiddleName = applicant.MiddleName,
                        LastName = applicant.LastName,
                        SSN = applicant.SSN,
                        Gender = applicant.Gender,
                        ApplicantAddress = applicant.ApplicantAddress,
                        Phone = applicant.Phone,
                        NameAlias = applicant.NameAlias
                    };

                    return (result != null ? result : null);
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }