public void EmploymentDAO_Test()
        {
            /*Context*/
            EmploymentDAO emp_context = new EmploymentDAO();
            AccountDAO account_context = new AccountDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            EmploymentDTO employment = new EmploymentDTO();
            employment.company = "fuzion";
            employment.country = "SA";
            employment.currentEmployer = "Apple";
            employment.empType = "Contract";
            employment.endDate = new DateTime(2012, 12, 30);
            employment.gross = 10000;
            employment.industry = "IT";
            employment.province = "WP";
            employment.responsibilities = "web development";
            employment.startDate = new DateTime(2012, 6, 7);
            employment.title = "web developer";
            employment.town = "cape town";
            employment.userName = "******";

            emp_context.presist(employment);

            bool expected = true;
            bool actual;
            actual = emp_context.isFound("griddy", new DateTime(2012, 6, 7) );
            Assert.AreEqual(expected, actual);

            /*Update*/
            employment.gross = 125000;
            emp_context.merge(employment);

            double expectedUpdate = 125000;
            EmploymentDTO contUpd = emp_context.find("griddy", new DateTime(2012, 6, 7));
            Assert.AreEqual(expectedUpdate, contUpd.gross);

            /*Delete*/
            emp_context.removeByUserId("griddy", new DateTime(2012, 6, 7));
            bool expectedDelete = false;
            bool actualDelete = emp_context.isFound("griddy", new DateTime(2012, 6, 7));
            Assert.AreEqual(expectedDelete, actualDelete);

            account_context.removeByUserId("griddy");
        }
 public void doDelete()
 {
     if (isMinimumValid())
     {
         EmploymentDAO employmentDao = new EmploymentDAO();
         employmentDao.removeByUserId(view.getUsername(), view.getStartDate());
         view.pageReload();
     }
     else
     {
         view.showFeedback("Error Field vlaues are not valid");
     }
 }
 public void doReset()
 {
     if (isMinimumValid())
     {
         EmploymentDAO employmentDao = new EmploymentDAO();
         EmploymentDTO employmentInfoDto = employmentDao.find(view.getUsername(), view.getStartDate());
         setEmploymentDto(employmentInfoDto);
         view.showFeedback("Fields are reset.");
     }
     else
     {
         view.showFeedback("Error Field vlaues are not valid");
     }
 }
예제 #4
0
        public bool PostEmployment(EmploymentDAO emp)
        {
            EmploymentServiceClient client = new EmploymentServiceClient();

            try
            {
                bool result = client.CreateEmployment(emp);
                return result;
            }
            catch (FaultException<KaskServiceException> e)
            {
                throw new HttpException(e.Message);
            }
        }
        public List<EmploymentDTO> getUserEmployment(String username)
        {
            List<EmploymentDTO> dtoList = new List<EmploymentDTO>();
            EmploymentDAO dao = new EmploymentDAO();
            List<EmploymentDTO> list = dao.findAll();

            foreach (EmploymentDTO emp in list)
            {
                if (emp.userName.Equals(username))
                {
                    dtoList.Add(emp);
                }
            }
            return dtoList;
        }
        protected void rptEmployment_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            EmploymentDTO dto;
            EmploymentDAO dao = new EmploymentDAO();
            String element = e.CommandName.ToString();

            if (element.Equals("startDate"))
            {
                dto = dao.find(getUsername(), DateTime.Parse(e.CommandArgument.ToString()));
                presenter.setEmploymentDto(dto);
                presenter.updateView();
            }
        }
 public void doSave()
 {
     AccountService accountService = new AccountServiceImpl();
     if (isValid())
     {
         if (accountService.isUniqueEmployment(view.getUsername(), view.getStartDate()))
         {
             EmploymentDAO employmentDao = new EmploymentDAO();
             employmentDao.presist(getEmploymentDto());
             view.pageReload();
         }
         else
         {
             view.setStartDateError("Error, this Date type is already used. Enter another value");
         }
     }
     else
     {
         view.showFeedback("Error Field vlaues are not valid");
     }
 }
 public void doUpdate()
 {
     if (isValid())
     {
         EmploymentDAO employmentInfoDao = new EmploymentDAO();
         employmentInfoDao.merge(getEmploymentDto());
         view.showFeedback("Successfully updated");
     }
     else
     {
         view.showFeedback("Error Field vlaues are not valid");
     }
 }
예제 #9
0
        public async Task<ActionResult> Create(FormCollection collection)
        {
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["FirstName"]) && !string.IsNullOrEmpty(Request.Form["LastName"]) && !string.IsNullOrEmpty(Request.Form["SSN"]) && Request.Form["acknowledgeAccurateDataCheckbox"] != null)
                {
                    // save application form data back to database through service
                    using (HttpClient httpClient = new HttpClient())
                    {
                        httpClient.BaseAddress = new Uri("http://localhost:51309");
                        httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                        HttpResponseMessage result = new HttpResponseMessage();
                        string resultContent = "";

                        // gather Applicant form data
                        ApplicantDAO applicant = new ApplicantDAO();
                        applicant.FirstName = Request.Form["FirstName"];
                        applicant.MiddleName = Request.Form["MiddleName"];
                        applicant.LastName = Request.Form["LastName"];
                        applicant.SSN = Request.Form["SSN"];
                        applicant.ApplicantAddress = Request.Form["ApplicantAddress"];
                        applicant.Phone = Request.Form["ApplicantPhone"];
                        applicant.NameAlias = Request.Form["NameAlias"];

                        // post (save) applicant data
                        result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceApplicantUri, applicant).Result;
                        resultContent = result.Content.ReadAsStringAsync().Result;

                        // gather Application form data
                        ApplicationDAO application = new ApplicationDAO();
                        application.ApplicationStatus = "Submitted";
                        application.SalaryExpectation = Request.Form["SalaryExpectation"];
                        application.FullTime = Convert.ToByte(Request.Form["FullTime"]);
                        application.AvailableForDays = Convert.ToByte(Request.Form["AvailableForDays"]);
                        application.AvailableForEvenings = Convert.ToByte(Request.Form["AvailableForEvenings"]);
                        application.AvailableForWeekends = Convert.ToByte(Request.Form["AvailableForWeekends"]);
                        application.MondayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["MondayFrom"]));
                        application.TuesdayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["TuesdayFrom"]));
                        application.WednesdayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["WednesdayFrom"]));
                        application.ThursdayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["ThursdayFrom"]));
                        application.FridayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["FridayFrom"]));
                        application.SaturdayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["SaturdayFrom"]));
                        application.SundayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["SundayFrom"]));
                        application.MondayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["MondayTo"]));
                        application.TuesdayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["TuesdayTo"]));
                        application.WednesdayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["WednesdayTo"]));
                        application.ThursdayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["ThursdayTo"]));
                        application.FridayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["FridayTo"]));
                        application.SaturdayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["SaturdayTo"]));
                        application.SundayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["SundayTo"]));

                        // post (save) application data
                        result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceApplicationUri, application).Result;
                        resultContent = result.Content.ReadAsStringAsync().Result;

                        // get correct applicant id
                        // TODO: there is still something we might need to change about this...
                        // ***** We don't, it's safe to assume that id would be the last item on the list
                        // since we're using auto incremented id. *****
                        var applicants = await ServerResponse<List<ApplicantDAO>>.GetResponseAsync(ServiceURIs.ServiceApplicantUri); ;
                        applicant.ApplicantID = applicants.Last().ApplicantID;

                        // get correct application id
                        // TODO: there is still something we might need to change about this...
                        var applications = await ServerResponse<List<ApplicationDAO>>.GetResponseAsync(ServiceURIs.ServiceApplicationUri);
                        application.ApplicationID = applications.Last().ApplicationID;

                        // Create Applied DAO;
                        AppliedDAO applied = new AppliedDAO();
                        applied.ApplicantID = applicant.ApplicantID;
                        applied.ApplicationID = application.ApplicationID;
                        applied.JobOpeningID = Convert.ToInt32(Request.Form["JobOpeningIDReferenceNumber"]);
                        applied.DateApplied = DateTime.Now;

                        // post (save) applied data
                        result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceAppliedUri, applied).Result;
                        resultContent = result.Content.ReadAsStringAsync().Result;

                        // gather Employer data
                        EmployerDAO employer = new EmployerDAO();
                        var employers = await ServerResponse<List<EmployerDAO>>.GetResponseAsync(ServiceURIs.ServiceEmployerUri);
                        EmploymentDAO employment = new EmploymentDAO();

                        for (int i = 1; i < 4; i++)
                        {
                            // make sure this form item is filled in...
                            if ((!string.IsNullOrWhiteSpace(Request.Form["EmployerName_" + i]) &&
                                  !string.IsNullOrWhiteSpace(Request.Form["EmployerAddress_" + i])))
                            {
                                employer.Name = Request.Form["EmployerName_" + i];
                                employer.EmployerAddress = Request.Form["EmployerAddress_" + i];
                                if (!string.IsNullOrWhiteSpace(Request.Form["EmployerPhone_" + i]))
                                    employer.PhoneNumber = Request.Form["EmployerPhone_" + i];

                                //if (!string.IsNullOrWhiteSpace(employer.Name))
                                //{
                                // TODO: check if employer already exists in database
                                // TODO: if employer exists in database: don't insert data
                                // if employer !exists in database: insert data

                                // post (save) employer data
                                result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceEmployerUri, employer).Result;
                                resultContent = result.Content.ReadAsStringAsync().Result;
                                //}

                                // get correct employer id
                                // TODO: there is still something we might need to change about this...
                                employers = await ServerResponse<List<EmployerDAO>>.GetResponseAsync(ServiceURIs.ServiceEmployerUri); ;
                                employer.EmployerID = employers.Last().EmployerID;


                                // gather Employment data
                                employment = new EmploymentDAO();
                                employment.ApplicantID = applicant.ApplicantID;
                                employment.EmployerID = employer.EmployerID;
                                if (!string.IsNullOrWhiteSpace(Request.Form["MayWeContactCurrentEmployer_" + i]))
                                    employment.MayWeContactCurrentEmployer = Convert.ToByte(Request.Form["MayWeContactCurrentEmployer_" + i]);
                                if (!string.IsNullOrWhiteSpace(Request.Form["EmployedFrom_" + i]))
                                    employment.EmployedFrom = Convert.ToDateTime(Request.Form["EmployedFrom_" + i]);
                                if (!string.IsNullOrWhiteSpace(Request.Form["EmployedTo_" + i]))
                                    employment.EmployedTo = Convert.ToDateTime(Request.Form["EmployedTo_" + i]);
                                if (!string.IsNullOrWhiteSpace(Request.Form["EmployerSupervisor_" + i]))
                                    employment.Supervisor = Request.Form["EmployerSupervisor_" + i];
                                if (!string.IsNullOrWhiteSpace(Request.Form["EmployedPosition_" + i]))
                                    employment.Position = Request.Form["EmployedPosition_" + i];
                                if (!string.IsNullOrWhiteSpace(Request.Form["EmployedStartingSalary_" + i]))
                                    employment.StartingSalary = Request.Form["EmployedStartingSalary_" + i];
                                if (!string.IsNullOrWhiteSpace(Request.Form["EmployedEndingSalary_" + i]))
                                    employment.EndingSalary = Request.Form["EmployedEndingSalary_" + i];
                                if (!string.IsNullOrWhiteSpace(Request.Form["EmployedReasonForLeaving_" + i]))
                                    employment.ReasonForLeaving = Request.Form["EmployedReasonForLeaving_" + i];
                                if (!string.IsNullOrWhiteSpace(Request.Form["EmployedResponsibilities_" + i]))
                                    employment.Responsibilities = Request.Form["EmployedResponsibilities_" + i];

                                // post (save) employment data
                                result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceEmploymentUri, employment).Result;
                                resultContent = result.Content.ReadAsStringAsync().Result;
                            }
                        }

                        // gather School and Education data
                        SchoolDAO school = new SchoolDAO();
                        var schools = await ServerResponse<List<SchoolDAO>>.GetResponseAsync(ServiceURIs.ServiceSchoolUri);
                        EducationDAO education = new EducationDAO();

                        for (int i = 1; i < 4; i++)
                        {
                            // make sure this form item is filled in...
                            if ((!string.IsNullOrWhiteSpace(Request.Form["SchoolName_" + i]) &&
                                  !string.IsNullOrWhiteSpace(Request.Form["SchoolAddress_" + i])))
                            {
                                school = new SchoolDAO();
                                school.SchoolName = Request.Form["SchoolName_" + i];
                                school.SchoolAddress = Request.Form["SchoolAddress_" + i];

                                //if (!string.IsNullOrWhiteSpace(school.SchoolName))
                                //{
                                // TODO: check if school already exists in database
                                // TODO: if school exists in database: don't insert data
                                // if school !exists in database: insert data

                                // post (save) school data
                                result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceSchoolUri, school).Result;
                                resultContent = result.Content.ReadAsStringAsync().Result;
                                //}

                                // get correct school id
                                // TODO: there is still something we might need to change about this...
                                schools = await ServerResponse<List<SchoolDAO>>.GetResponseAsync(ServiceURIs.ServiceSchoolUri);
                                school.SchoolID = schools.Last().SchoolID;

                                // gather Education data
                                education = new EducationDAO();
                                education.ApplicantID = applicant.ApplicantID;
                                education.SchoolID = school.SchoolID;
                                if (!string.IsNullOrWhiteSpace(Request.Form["YearsAttendedFrom_" + i]))
                                    education.YearsAttendedFrom = Convert.ToDateTime(Request.Form["YearsAttendedFrom_" + i]);
                                if (!string.IsNullOrWhiteSpace(Request.Form["YearsAttendedTo_" + i]))
                                    education.YearsAttendedTo = Convert.ToDateTime(Request.Form["YearsAttendedTo_" + i]);
                                if (!string.IsNullOrWhiteSpace(Request.Form["Graduated_" + i]))
                                    education.Graduated = Convert.ToByte(Request.Form["Graduated_" + i]);
                                if (!string.IsNullOrWhiteSpace(Request.Form["DegreeAndMajor_" + i]))
                                    education.DegreeAndMajor = Request.Form["DegreeAndMajor_" + i];

                                // post (save) education data
                                result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceEducationUri, education).Result;
                                resultContent = result.Content.ReadAsStringAsync().Result;
                            }
                        }
                    }

                    try
                    {
                        // redirect to assessment questions, if possible
                        return RedirectToAction("Create", "Assessments", new { ID = Convert.ToInt32(Request.Form["JobOpeningIDReferenceNumber"]) });
                    }
                    catch
                    {
                        return RedirectToAction("Welcome", "Home");
                    }
                }
                else
                {
                    // TODO: validation later on...
                    return RedirectToAction("Create");
                }
            }
            catch
            {
                // TODO: validation later on...
                return RedirectToAction("Create");
            }
        }
 public bool isUniqueEmployment(String username, DateTime startdate)
 {
     bool isUnique = false;
     EmploymentDAO dao = new EmploymentDAO();
     try
     {
         return (!dao.isFound(username, startdate));
     }
     catch (InvalidOperationException ioe)
     {
         isUnique = true;
     }
     return isUnique;
 }