public void Test_UpdateApplication()
 {
     ApplicationDAO application4 = new ApplicationDAO() { ID = 3, ApplicationID = 3, ApplicationStatus = "TestStatus2", SalaryExpectation = "TestSalary2" };
     applicationService.UpdateApplication(application4);
     Assert.AreEqual(applicationService.GetApplicationByID(3).SalaryExpectation, "TestSalary2");
     Assert.AreEqual(applicationService.GetApplications().Count, 3);
 }
 private void initializeApplication(ApplicationDAO application, int id, int applicationID, string applicationStatus, string salaryExpect )
 {
     //ApplicationDAO application = new ApplicationDAO();
     application.ID = id;
     application.ApplicationID = applicationID;
     application.ApplicationStatus = applicationStatus;
     application.SalaryExpectation = salaryExpect;
     application.FullTime = null;
     application.AvailableForDays = null;
     application.AvailableForEvenings = null;
     application.AvailableForWeekends = null;
     application.MondayFrom = null;
     application.TuesdayFrom = null;
     application.WednesdayFrom = null;
     application.ThursdayFrom = null;
     application.FridayFrom = null;
     application.SaturdayFrom = null;
     application.SundayFrom = null;
     application.MondayTo = null;
     application.TuesdayTo = null;
     application.WednesdayTo = null;
     application.ThursdayTo = null;
     application.FridayTo = null;
     application.SaturdayTo = null;
     application.SundayTo = null;
 }
 public void Test_CreateApplication()
 {
     ApplicationDAO application4 = new ApplicationDAO() { ID = 4, ApplicationID = 4, ApplicationStatus = "TestStatus", SalaryExpectation = "TestSalary" };
     applicationService.CreateApplication(application4);
     Assert.AreEqual(applicationService.GetApplicationByID(4).SalaryExpectation, "TestSalary");
     Assert.AreEqual(applicationService.GetApplications().Count, 4);
 }
        internal void SetUp()
        {
            ApplicationDAO applicationA = new ApplicationDAO() { ID = 1, ApplicationID = 1, ApplicationStatus = "Rejected", SalaryExpectation = "20.00" };
            ApplicationDAO applicationB = new ApplicationDAO() { ID = 2, ApplicationID = 2, ApplicationStatus = "Accepted", SalaryExpectation = "21.00" };
            ApplicationDAO applicationC = new ApplicationDAO() { ID = 3, ApplicationID = 3, ApplicationStatus = "Reviewed", SalaryExpectation = "22.00" };

            Applications.Add(applicationA);
            Applications.Add(applicationB);
            Applications.Add(applicationC);
        }
 public bool UpdateApplication(ApplicationDAO newApp)
 {
     foreach (var application in Applications)
         if (application.ApplicationID == newApp.ApplicationID)
         {
             Applications.Remove(application);
             Applications.Add(newApp);
             return true;
         }
     return false;
 }
        public bool CreateApplication(ApplicationDAO app)
        {
            Application a = new Application
            {
                Application_ID = app.ApplicationID,
                ApplicationStatus = app.ApplicationStatus,
                SalaryExpectation = app.SalaryExpectation,
                FullTime = app.FullTime,
                AvailableForDays = app.AvailableForDays,
                AvailableForEvenings = app.AvailableForEvenings,
                AvailableForWeekends = app.AvailableForWeekends,
                MondayFrom = app.MondayFrom,
                TuesdayFrom = app.TuesdayFrom,
                WednesdayFrom = app.WednesdayFrom,
                ThursdayFrom = app.ThursdayFrom,
                FridayFrom = app.FridayFrom,
                SaturdayFrom = app.SaturdayFrom,
                SundayFrom = app.SundayFrom,
                MondayTo = app.MondayTo,
                TuesdayTo = app.TuesdayTo,
                WednesdayTo = app.WednesdayTo,
                ThursdayTo = app.ThursdayTo,
                FridayTo = app.FridayTo,
                SaturdayTo = app.SaturdayTo,
                SundayTo = app.SundayTo
            };

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

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

            return true;
        }
 public bool CreateApplication(ApplicationDAO app)
 {
     Applications.Add(app);
     return true;
 }
        public bool UpdateApplication(ApplicationDAO newApp)
        {
            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                Application a = db.Applications.Single(app => app.Application_ID == newApp.ApplicationID);
                a.ApplicationStatus = newApp.ApplicationStatus;
                a.AvailableForDays = newApp.AvailableForDays;
                a.AvailableForEvenings = newApp.AvailableForEvenings;
                a.AvailableForWeekends = newApp.AvailableForWeekends;
                a.FridayFrom = newApp.FridayFrom;
                a.FridayTo = newApp.FridayTo;
                a.FullTime = newApp.FullTime;
                a.MondayFrom = newApp.MondayFrom;
                a.MondayTo = newApp.MondayTo;
                a.SalaryExpectation = newApp.SalaryExpectation;
                a.SaturdayFrom = newApp.SaturdayFrom;
                a.SaturdayTo = newApp.SaturdayTo;
                a.SundayFrom = newApp.SundayFrom;
                a.SundayTo = newApp.SundayTo;
                a.ThursdayFrom = newApp.ThursdayFrom;
                a.ThursdayTo = newApp.ThursdayTo;
                a.TuesdayFrom = newApp.TuesdayFrom;
                a.TuesdayTo = newApp.TuesdayTo;
                a.WednesdayFrom = newApp.WednesdayFrom;
                a.WednesdayTo = newApp.WednesdayTo;

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

            return true;
        }
        // get applications for this particular applicant ID
        public IList<ApplicationDAO> GetApplicationsByApplicant(int id)
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    IList<Applied> allApplieds = (from a in db.Applieds where a.Applicant_ID==id select a).ToList();
                    IList<Application> allApplications = (from a in db.Applications select a).ToList();
                    List<ApplicationDAO> result = new List<ApplicationDAO>();

                    foreach (var applied in allApplieds)
                    {
                        foreach (var application in allApplications)
                        {
                            if (applied.Application_ID == application.Application_ID)
                            {
                                ApplicationDAO app = new ApplicationDAO
                                {
                                    ApplicationID = application.Application_ID,
                                    ID = application.Application_ID,
                                    ApplicationStatus = application.ApplicationStatus,
                                    SalaryExpectation = application.SalaryExpectation,
                                    FullTime = application.FullTime,
                                    AvailableForDays = application.AvailableForDays,
                                    AvailableForEvenings = application.AvailableForEvenings,
                                    AvailableForWeekends = application.AvailableForWeekends,
                                    MondayFrom = application.MondayFrom,
                                    TuesdayFrom = application.TuesdayFrom,
                                    WednesdayFrom = application.WednesdayFrom,
                                    ThursdayFrom = application.ThursdayFrom,
                                    FridayFrom = application.FridayFrom,
                                    SaturdayFrom = application.SaturdayFrom,
                                    SundayFrom = application.SundayFrom,
                                    MondayTo = application.MondayTo,
                                    TuesdayTo = application.TuesdayTo,
                                    WednesdayTo = application.WednesdayTo,
                                    ThursdayTo = application.ThursdayTo,
                                    FridayTo = application.FridayTo,
                                    SaturdayTo = application.SaturdayTo,
                                    SundayTo = application.SundayTo
                                };

                                result.Add(app);
                            }
                        }
                    }

                    return result;
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }
        public IList<ApplicationDAO> GetApplications()
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    IList<Application> apps = db.Applications.ToList();
                    List<ApplicationDAO> result = new List<ApplicationDAO>();

                    foreach (var application in apps)
                    {
                        ApplicationDAO temp = new ApplicationDAO
                        {
                            ApplicationID = application.Application_ID,
                            ID = application.Application_ID,
                            ApplicationStatus = application.ApplicationStatus,
                            SalaryExpectation = application.SalaryExpectation,
                            FullTime = application.FullTime,
                            AvailableForDays = application.AvailableForDays,
                            AvailableForEvenings = application.AvailableForEvenings,
                            AvailableForWeekends = application.AvailableForWeekends,
                            MondayFrom = application.MondayFrom,
                            TuesdayFrom = application.TuesdayFrom,
                            WednesdayFrom = application.WednesdayFrom,
                            ThursdayFrom = application.ThursdayFrom,
                            FridayFrom = application.FridayFrom,
                            SaturdayFrom = application.SaturdayFrom,
                            SundayFrom = application.SundayFrom,
                            MondayTo = application.MondayTo,
                            TuesdayTo = application.TuesdayTo,
                            WednesdayTo = application.WednesdayTo,
                            ThursdayTo = application.ThursdayTo,
                            FridayTo = application.FridayTo,
                            SaturdayTo = application.SaturdayTo,
                            SundayTo = application.SundayTo
                        };

                        result.Add(temp);
                    }
                    return (result != null ? result : null);
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }
 public ApplicationDAO GetApplicationByID(int id)
 {
     try
     {
         using (AESDatabaseDataContext db = new AESDatabaseDataContext())
         {
             Application application = (from a in db.Applications where a.Application_ID == id select a).FirstOrDefault();
             ApplicationDAO result = new ApplicationDAO
             {
                 ApplicationID = application.Application_ID,
                 ID = application.Application_ID,
                 ApplicationStatus = application.ApplicationStatus,
                 SalaryExpectation = application.SalaryExpectation,
                 FullTime = application.FullTime,
                 AvailableForDays = application.AvailableForDays,
                 AvailableForEvenings = application.AvailableForEvenings,
                 AvailableForWeekends = application.AvailableForWeekends,
                 MondayFrom = application.MondayFrom,
                 TuesdayFrom = application.TuesdayFrom,
                 WednesdayFrom = application.WednesdayFrom,
                 ThursdayFrom = application.ThursdayFrom,
                 FridayFrom = application.FridayFrom,
                 SaturdayFrom = application.SaturdayFrom,
                 SundayFrom = application.SundayFrom,
                 MondayTo = application.MondayTo,
                 TuesdayTo = application.TuesdayTo,
                 WednesdayTo = application.WednesdayTo,
                 ThursdayTo = application.ThursdayTo,
                 FridayTo = application.FridayTo,
                 SaturdayTo = application.SaturdayTo,
                 SundayTo = application.SundayTo
             };
             return (result != null ? result : null);
         }
     }
     catch (Exception e)
     {
         throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
     }
 }