예제 #1
0
        public bool PostJobRequirement(JobRequirementDAO jobRequirementRequirement)
        {
            JobRequirementServiceClient client = new JobRequirementServiceClient();

            try
            {
                bool result = client.CreateJobRequirement(jobRequirementRequirement);
                return result;
            }
            catch (FaultException<KaskServiceException> e)
            {
                throw new HttpException(e.Message);
            }
        }
예제 #2
0
        public async Task<ActionResult> Create(FormCollection collection)
        {
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["JobID"]))
                {
                    // 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 JobOpening form data
                        JobOpeningDAO jobOpening = new JobOpeningDAO();
                        jobOpening.OpenDate = DateTime.Now; // note: this could change to the above "OpenDate" line of code in the future...
                        jobOpening.JobID = Convert.ToInt32(Request.Form["JobID"]);
                        jobOpening.Approved = 0;    // "not approved" by default
                        jobOpening.Description = Request.Form["Description"];
                        jobOpening.StoreID = Convert.ToInt32(Request.Form["StoreID"]);

                        // post (save) JobOpening data
                        result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceJobOpeningUri, jobOpening).Result;
                        resultContent = result.Content.ReadAsStringAsync().Result;

                        // save job requirement data
                        // 1. see which checkboxes are checked
                        // 2. create new JobRequirement entries and tie those back to this JobOpening

                        // get correct job opening id of the job opening we just saved
                        var jobOpenings = await ServerResponse<List<JobOpeningDAO>>.GetResponseAsync(ServiceURIs.ServiceJobOpeningUri);
                        int jobOpeningId = jobOpenings.Last().JobOpeningID;

                        // TODO: change the hardcoded "50" into the length of all available skills
                        for (int i = 0; i < 50; i++)
                        {
                            try
                            {
                                if (Request.Form["Skill_" + i] != null)
                                {
                                    // NOTE: renamed Job_ID to JobOpening_ID in JobRequirement table?
                                    // because we aren't really linking these requirements to a "job type" in the Job table
                                    // we are actually linking these to JobOpenings...
                                    JobRequirementDAO jobRequirement = new JobRequirementDAO();
                                    jobRequirement.JobOpeningID = jobOpeningId;
                                    jobRequirement.SkillID = i;

                                    // post (save) JobRequirement data
                                    result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceJobRequirementUri, jobRequirement).Result;
                                    resultContent = result.Content.ReadAsStringAsync().Result;
                                }
                            }
                            catch { }
                        }

                        // TODO: change the hardcoded "50" into the length of all available short answer questions
                        for (int i = 0; i < 50; i++)
                        {
                            try
                            {
                                if (Request.Form["SAQuestion_" + i] != null)
                                {
                                    JobOpeningInterviewQuestionDAO jobOpeningInterviewQuestion = new JobOpeningInterviewQuestionDAO();
                                    jobOpeningInterviewQuestion.JobOpeningID = jobOpeningId;
                                    jobOpeningInterviewQuestion.SAQuestionID = Convert.ToInt32(Request.Form["SAQuestion_" + i]);

                                    // post (save) which SA Questions we want to use for this Job Opening
                                    result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceJobOpeningInterviewQuestionUri, jobOpeningInterviewQuestion).Result;
                                    resultContent = result.Content.ReadAsStringAsync().Result;
                                }
                            }
                            catch { }
                        }
                    }

                    return RedirectToAction("Backend", "Home");
                }
                else
                {
                    // TODO: validation later on...
                    return RedirectToAction("Create");
                }
            }
            catch
            {
                // TODO: validation later on...
                return RedirectToAction("Create");
            }
        }