public bool PostUserProfileToApplicant(UserProfileToApplicantDAO usproToApplicant)
        {
            UserProfileToApplicantServiceClient client = new UserProfileToApplicantServiceClient();

            try
            {
                bool result = client.CreateUserProfileToApplicant(usproToApplicant);
                return result;
            }
            catch (FaultException<KaskServiceException> e)
            {
                throw new HttpException(e.Message);
            }
        }
Beispiel #2
0
        public async Task<ActionResult> MapToUserProfile()
        {
            // get latest applicant ID and map to latest user ID account
            // this is used to relate data between two separate database table entities (Applicant and UserProfile)
            
            // get latest applicant ID
            var applicants = await ServerResponse<List<ApplicantDAO>>.GetResponseAsync(ServiceURIs.ServiceApplicantUri);
            int applicantID = applicants.Last().ApplicantID;

            // get latest user ID
            var userProfiles = await ServerResponse<List<UserProfileDAO>>.GetResponseAsync(ServiceURIs.ServiceUserProfileUri);
            int userProfileID = userProfiles.Last().UserId;

            // save mapping 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 = "";

                // save mapped results to UserProfileToApplicant table
                UserProfileToApplicantDAO userProfileToApplicant = new UserProfileToApplicantDAO();
                userProfileToApplicant.Applicant_ID = applicantID;
                userProfileToApplicant.UserId = userProfileID;

                // post (save) AssessmentOpening data
                result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceUserProfileToApplicantUri, userProfileToApplicant).Result;
                resultContent = result.Content.ReadAsStringAsync().Result;
            }

            return RedirectToAction("Welcome", "Home");
        }