public async Task <IActionResult> SaveApplication([FromBody] ApplicationFormModel model) { if (model == null) { if (ModelState.ErrorCount > 0) { var errors = ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage)); return(new JsonResult(new { IsSuccess = false, Status = "Application Save Error", Message = "Errors in binding: " + string.Join(Environment.NewLine, errors) })); } else { return(new JsonResult(new { IsSuccess = false, Status = "Application Save Error", Message = "Error: Model is null." })); } } var t = Task.Run(() => CreateCaseAction(_configuration, model)); t.Wait(); string tempString = Newtonsoft.Json.JsonConvert.SerializeObject(t); var dynamicsResponse = JsonConvert.DeserializeObject <DynamicsResponse>(tempString); var result = new { IsSuccess = dynamicsResponse.IsCompletedSuccessfully, Status = "Application Save", Message = dynamicsResponse.Result }; return(new JsonResult(result)); }
public async Task <IActionResult> Edit(string appid) { Application app = _mapper.Map <Application>(await _applicationProcessor.GetApplicationById(appid)); if (app == null) { return(RedirectToAction("Index")); } else { var authorizationResult = await _authorizationService.AuthorizeAsync(User, app, "ApplicationPolicy"); if (authorizationResult.Succeeded) { ApplicationFormModel viewModel = new ApplicationFormModel { Name = app.Name, RedirectUri = app.RedirectUri }; return(View(viewModel)); } else { return(RedirectToAction("Index")); } } }
public async Task <IActionResult> Edit(string appid, ApplicationFormModel appForm) { if (ModelState.IsValid) { Application app = _mapper.Map <Application>(_applicationProcessor.GetApplicationById(appid)); if (app != null) { if ((await _authorizationService.AuthorizeAsync(User, app, "ApplicationPolicy")).Succeeded) { if (await _applicationProcessor.GetApplicationByUserAndName(User.Identity.Name, appForm.Name) == null) { if (string.IsNullOrWhiteSpace(appForm.RedirectUri)) { appForm.RedirectUri = "localhost:6969"; } app = new Application { Id = appid, Author = _mapper.Map <User>(await _userProcessor.GetUserById(User.Identity.Name)), Name = appForm.Name, RedirectUri = appForm.RedirectUri }; await _applicationProcessor.UpdateApplication(_mapper.Map <DataAccessLibrary.Models.Application>(app)); return(RedirectToAction("Index")); // TODO: Add alert with success message } else { ModelState.AddModelError("Name", "You have already created an application with this name."); return(View(appForm)); } } else { return(RedirectToAction("Index")); // TODO: Add alert with unauthorized error } } else { throw new ArgumentException("Application does not exist."); // TODO: Add alert with error } } else { return(View(appForm)); } }
public async Task <IActionResult> Create(ApplicationFormModel appForm) { if (ModelState.IsValid) { if (await _applicationProcessor.GetApplicationByUserAndName(User.Identity.Name, appForm.Name) == null) // Check if application already exists { bool secret = appForm.Type == ApplicationFormModel.ApplicationType.WebServer; // Only generate secret for webserver applications if (string.IsNullOrWhiteSpace(appForm.RedirectUri)) { appForm.RedirectUri = "localhost:6969"; } var app = new Application { Author = _mapper.Map <User>(await _userProcessor.GetUserById(User.Identity.Name)), Name = appForm.Name, RedirectUri = appForm.RedirectUri }; await _applicationProcessor.CreateApplication(_mapper.Map <DataAccessLibrary.Models.Application>(app), secret); return(RedirectToAction("Index")); } else { ModelState.AddModelError("Name", "You have already created an application with this name."); return(View(appForm)); } } else { return(View(appForm)); } }
public static ApplicationDynamicsModel ToVsdVictimsModel(this ApplicationFormModel model) { var application = GetApplicationDefaults(); application.Application.vsd_applicanttype = (int)ApplicationType.Victim; if (model == null) { return(null); } if (model.PersonalInformation != null) { application.Application.vsd_applicantsfirstname = model.PersonalInformation.firstName; application.Application.vsd_applicantsmiddlename = model.PersonalInformation.middleName; application.Application.vsd_applicantslastname = model.PersonalInformation.lastName; application.Application.vsd_otherfirstname = model.PersonalInformation.otherFirstName; application.Application.vsd_otherlastname = model.PersonalInformation.otherLastName; if (model.PersonalInformation.dateOfNameChange.HasValue) { application.Application.vsd_dateofnamechange = model.PersonalInformation.dateOfNameChange; } application.Application.vsd_applicantsgendercode = model.PersonalInformation.gender; if (model.PersonalInformation.birthDate.HasValue) { application.Application.vsd_applicantsbirthdate = model.PersonalInformation.birthDate.Value; } application.Application.vsd_applicantsmaritalstatus = model.PersonalInformation.maritalStatus; application.Application.vsd_applicantsoccupation = model.PersonalInformation.occupation; application.Application.vsd_applicantssocialinsurancenumber = model.PersonalInformation.sin; // what format does dynamics expect in the JSON? // currently the Dynamics UI only allows a 10-digit number and uses some fancy input masking to include the parens and hyphens // Form side should mimic the fancy javascript input masking from the Dynamics UI, and probably just represent it as a pure 10 digit number behind the scenes and in the JSON // Ideally the whole thing would support international numbers and use the E.164 standard for behind-the-scenes representation // (see https://www.sitepoint.com/working-phone-numbers-javascript/ for inspiration) // but for now we should only support whatever the Dynamics UI supports - no sense adding extra features that can't be used because of the Dynamics side application.Application.vsd_applicantsprimaryphonenumber = model.PersonalInformation.phoneNumber; application.Application.vsd_applicantsalternatephonenumber = model.PersonalInformation.alternatePhoneNumber; application.Application.vsd_applicantsemail = model.PersonalInformation.email; application.Application.vsd_applicantspreferredmethodofcontact = model.PersonalInformation.preferredMethodOfContact; if (model.PersonalInformation.primaryAddress != null) { application.Application.vsd_applicantsprimaryaddressline1 = model.PersonalInformation.primaryAddress.line1; application.Application.vsd_applicantsprimaryaddressline2 = model.PersonalInformation.primaryAddress.line2; application.Application.vsd_applicantsprimarycity = model.PersonalInformation.primaryAddress.city; application.Application.vsd_applicantsprimaryprovince = model.PersonalInformation.primaryAddress.province; application.Application.vsd_applicantsprimarycountry = model.PersonalInformation.primaryAddress.country; application.Application.vsd_applicantsprimarypostalcode = model.PersonalInformation.primaryAddress.postalCode; } if (model.PersonalInformation.alternateAddress != null) { application.Application.vsd_applicantsalternateaddressline1 = model.PersonalInformation.alternateAddress.line1; application.Application.vsd_applicantsalternateaddressline2 = model.PersonalInformation.alternateAddress.line2; application.Application.vsd_applicantsalternatecity = model.PersonalInformation.alternateAddress.city; application.Application.vsd_applicantsalternateprovince = model.PersonalInformation.alternateAddress.province; application.Application.vsd_applicantsalternatecountry = model.PersonalInformation.alternateAddress.country; application.Application.vsd_applicantsalternatepostalcode = model.PersonalInformation.alternateAddress.postalCode; } } if (model.CrimeInformation != null) { application.Application.vsd_cvap_typeofcrime = model.CrimeInformation.typeOfCrime; if (model.CrimeInformation.crimePeriodStart.HasValue) { application.Application.vsd_cvap_crimestartdate = model.CrimeInformation.crimePeriodStart; } if (model.CrimeInformation.crimePeriodEnd.HasValue) { application.Application.vsd_cvap_crimeenddate = model.CrimeInformation.crimePeriodEnd; } application.Application.vsd_cvap_reasontoapplylate = model.CrimeInformation.whyDidYouNotApplySooner; // TODO: Verify mapping - I think it's right but just different names // Add Crime Locations as an array separated by line feeds if (model.CrimeInformation.crimeLocations.Count() > 0) { string tempOutput = ""; foreach (Crimelocation tempCrimeLocation in model.CrimeInformation.crimeLocations) { tempOutput = tempOutput + tempCrimeLocation.location + "\r\n"; } application.Application.vsd_cvap_crimelocations = tempOutput.Substring(0, tempOutput.Length - 2); } application.Application.vsd_cvap_crimedetails = model.CrimeInformation.crimeDetails; application.Application.vsd_cvap_injuries = model.CrimeInformation.crimeInjuries; // Include upload file try { if (model.CrimeInformation.additionalInformationFiles != null) { if (model.CrimeInformation.additionalInformationFiles.fileName.Length > 0) { Documentcollection tempDocumentCollection = new Documentcollection(); tempDocumentCollection.body = model.CrimeInformation.additionalInformationFiles.body; tempDocumentCollection.filename = model.CrimeInformation.additionalInformationFiles.fileName; application.DocumentCollection = new Documentcollection[1]; application.DocumentCollection[0] = tempDocumentCollection; } } } catch (Exception e) { string errormessage = e.Message; } application.Application.vsd_cvap_reportedtopolice = model.CrimeInformation.wasReportMadeToPolice; application.Application.vsd_cvap_policedetachment = model.CrimeInformation.policeReportedWhichPoliceForce; if (model.CrimeInformation.policeReportedDate.HasValue) { application.Application.vsd_cvap_policereportingstartdate = model.CrimeInformation.policeReportedDate; } if (model.CrimeInformation.policeReportedEndDate.HasValue) { application.Application.vsd_cvap_policereportingenddate = model.CrimeInformation.policeReportedEndDate; } application.Application.vsd_cvap_crimereportedto = model.CrimeInformation.noPoliceReportIdentification; // TODO: verify mapping - I think it's right, but different names // Setup policeFiles, don't show if there isn't any if (model.CrimeInformation.policeReports != null) { if (model.CrimeInformation.policeReports[0].policeFileNumber.Length > 0) { application.PoliceFileNumberCollection = model.CrimeInformation.policeReports.Select(r => new Policefilenumbercollection { vsd_investigatingpoliceofficername = r.investigatingOfficer, vsd_policefilenumber = r.policeFileNumber }).ToArray(); } } application.Application.vsd_cvap_offenderfirstname = model.CrimeInformation.offenderFirstName; application.Application.vsd_cvap_offendermiddlename = model.CrimeInformation.offenderMiddleName; application.Application.vsd_cvap_offenderlastname = model.CrimeInformation.offenderLastName; application.Application.vsd_cvap_relationshiptooffender = model.CrimeInformation.offenderRelationship; application.Application.vsd_cvap_isoffendercharged = model.CrimeInformation.offenderBeenCharged; // Setup courtFiles, don't show if there isn't any if (model.CrimeInformation.courtFiles != null) { if (model.CrimeInformation.courtFiles[0].courtFileNumber.Length > 0) { application.CourtInfoCollection = model.CrimeInformation.courtFiles.Select(f => new Courtinfocollection { vsd_courtfilenumber = f.courtFileNumber, vsd_courtlocation = f.courtLocation }).ToArray(); } } application.Application.vsd_cvap_isoffendersued = model.CrimeInformation.haveYouSuedOffender; application.Application.vsd_cvap_intentiontosueoffender = model.CrimeInformation.intendToSueOffender; if (model.CrimeInformation.racafInformation != null) { application.Application.vsd_racaf_appliedforrestitution = model.CrimeInformation.racafInformation.applyToCourtForMoneyFromOffender; application.Application.vsd_racaf_requestedexpenses = model.CrimeInformation.racafInformation.expensesRequested; application.Application.vsd_racaf_expensesawarded = model.CrimeInformation.racafInformation.expensesAwarded; application.Application.vsd_racaf_amountreceived = model.CrimeInformation.racafInformation.expensesReceived; application.Application.vsd_racaf_legalactiontaken = model.CrimeInformation.racafInformation.willBeTakingLegalAction; application.Application.vsd_racaf_lawyerorfirmname = model.CrimeInformation.racafInformation.lawyerOrFirmName; application.Application.vsd_racaf_lawyeraddressline1 = model.CrimeInformation.racafInformation.lawyerAddress?.line1; application.Application.vsd_racaf_lawyeraddressline2 = model.CrimeInformation.racafInformation.lawyerAddress?.line2; application.Application.vsd_racaf_lawyercity = model.CrimeInformation.racafInformation.lawyerAddress?.city; application.Application.vsd_racaf_lawyerprovince = model.CrimeInformation.racafInformation.lawyerAddress?.province; application.Application.vsd_racaf_lawyerpostalcode = model.CrimeInformation.racafInformation.lawyerAddress?.postalCode; application.Application.vsd_racaf_lawyercountry = model.CrimeInformation.racafInformation.lawyerAddress?.country; application.Application.vsd_racaf_signature = model.CrimeInformation.racafInformation.signature; } } if (model.MedicalInformation != null) { application.Application.vsd_applicantspersonalhealthnumber = model.MedicalInformation.personalHealthNumber; application.Application.vsd_applicantsextendedhealthprovidername = model.MedicalInformation.otherHealthCoverageProviderName; // TODO: verify mapping, "other" seems weird here application.Application.vsd_applicantsextendedhealthnumber = model.MedicalInformation.otherHealthCoverageExtendedPlanNumber; // TODO: verify mapping, "other" seems weird here application.Application.vsd_cvap_treatmenthospitalname = model.MedicalInformation.treatedAtHospitalName; if (model.MedicalInformation.treatedAtHospitalDate.HasValue) { application.Application.vsd_cvap_treatmentdate = model.MedicalInformation.treatedAtHospitalDate; } // Setup otherTreatments, don't show if there isn't any if (model.MedicalInformation.otherTreatments != null) { if (model.MedicalInformation.otherTreatments[0].providerName.Length > 0) { application.ProviderCollection = model.MedicalInformation.otherTreatments.Select(t => new Providercollection { vsd_name = t.providerName, vsd_phonenumber = t.providerPhoneNumber, vsd_addressline1 = t.providerAddress.line1, vsd_addressline2 = t.providerAddress.line2, vsd_city = t.providerAddress.city, vsd_province = t.providerAddress.province, vsd_country = t.providerAddress.country, vsd_postalcode = t.providerAddress.postalCode, vsd_relationship1 = t.providerType.ToString(), // // TODO: It looks like we're using this object in two different places - confirm that we can safely ignore the following fields in this context // vsd_firstname = "", // TODO: We don't collect a split name here // vsd_middlename = "", // TODO: We don't collect a split name here // vsd_lastname = "", // TODO: We don't collect a split name here // vsd_alternatephonenumber = "", // TODO: We don't collect an alternate phone number // vsd_email = "", // TODO: We don't collect an email here // //vsd_preferredmethodofcontact = 1, // TODO: We don't collect a contact method here // //vsd_preferredmethodofcontact = model.RepresentativeInformation.representativePreferredMethodOfContact, // TODO: This isn't correct either // vsd_relationship1 = "", // TODO: We don't collect a relationship here }).ToArray(); } } } // Add employer information to Provider collection if (model.EmploymentIncomeInformation != null) { if (model.EmploymentIncomeInformation.employers.Count() > 0) { if (model.EmploymentIncomeInformation.employers[0].employerFirstName != null) { Providercollection[] tempProviderCollection; tempProviderCollection = model.EmploymentIncomeInformation.employers.Select(f => new Providercollection { vsd_name = f.employerName, vsd_phonenumber = f.employerPhoneNumber, vsd_addressline1 = f.employerAddress.line1, vsd_addressline2 = f.employerAddress.line2, vsd_city = f.employerAddress.city, vsd_province = f.employerAddress.province, vsd_postalcode = f.employerAddress.postalCode, vsd_country = f.employerAddress.country, vsd_firstname = f.employerFirstName, vsd_lastname = f.employerLastName, vsd_relationship1 = "100000005", // TODO: This is just an assumption, looking for confirmation from Mano }).ToArray(); int tempProviderCount = 0; if (application.ProviderCollection == null) { tempProviderCount = 0; } else { tempProviderCount = application.ProviderCollection.Count(); } Providercollection[] tempCombinedCollection = new Providercollection[tempProviderCount + tempProviderCollection.Count()]; if (application.ProviderCollection == null) { tempCombinedCollection = tempProviderCollection; } else { Array.Copy(application.ProviderCollection, tempCombinedCollection, tempProviderCount); } Array.Copy(tempProviderCollection, 0, tempCombinedCollection, tempProviderCount, tempProviderCollection.Count()); application.ProviderCollection = tempCombinedCollection; } } } // Add medical doctor information if (model.MedicalInformation.familyDoctorName.Length > 0) // Only do this if there is something in this field { Providercollection[] tempProviderCollection = new Providercollection[1]; tempProviderCollection[0] = new Providercollection(); tempProviderCollection[0].vsd_name = model.MedicalInformation.familyDoctorName; tempProviderCollection[0].vsd_phonenumber = model.MedicalInformation.familyDoctorPhoneNumber; tempProviderCollection[0].vsd_addressline1 = model.MedicalInformation.familyDoctorAddressLine1; tempProviderCollection[0].vsd_addressline2 = model.MedicalInformation.familyDoctorAddressLine2; tempProviderCollection[0].vsd_relationship1 = "100000000"; // TODO: This is just an assumption, looking for confirmation from Mano int tempProviderCount = 0; if (application.ProviderCollection == null) { tempProviderCount = 0; } else { tempProviderCount = application.ProviderCollection.Count(); } Providercollection[] tempCombinedCollection = new Providercollection[tempProviderCount + tempProviderCollection.Count()]; if (application.ProviderCollection == null) { tempCombinedCollection = tempProviderCollection; } else { Array.Copy(application.ProviderCollection, tempCombinedCollection, tempProviderCount); } Array.Copy(tempProviderCollection, 0, tempCombinedCollection, tempProviderCount, tempProviderCollection.Count()); application.ProviderCollection = tempCombinedCollection; } if (model.ExpenseInformation != null) { // Build Expenses CSV String string tempExpenses = ""; if (model.ExpenseInformation.haveMedicalExpenses) { tempExpenses = tempExpenses + "100000000,"; } if (model.ExpenseInformation.haveDentalExpenses) { tempExpenses = tempExpenses + "100000001,"; } if (model.ExpenseInformation.havePrescriptionDrugExpenses) { tempExpenses = tempExpenses + "100000002,"; } if (model.ExpenseInformation.haveCounsellingExpenses) { tempExpenses = tempExpenses + "100000003,"; } if (model.ExpenseInformation.haveLostEmploymentIncomeExpenses) { tempExpenses = tempExpenses + "100000004,"; } if (model.ExpenseInformation.havePersonalPropertyLostExpenses) { tempExpenses = tempExpenses + "100000005,"; } if (model.ExpenseInformation.haveProtectiveMeasureExpenses) { tempExpenses = tempExpenses + "100000006,"; } if (model.ExpenseInformation.haveDisabilityExpenses) { tempExpenses = tempExpenses + "100000007,"; } if (model.ExpenseInformation.haveCrimeSceneCleaningExpenses) { tempExpenses = tempExpenses + "100000008,"; } if (model.ExpenseInformation.haveOtherExpenses) { tempExpenses = tempExpenses + "100000009,"; } if (tempExpenses.Length > 0) { tempExpenses = tempExpenses.Substring(0, tempExpenses.Length - 1); application.Application.vsd_cvap_benefitsrequested = tempExpenses; } application.Application.vsd_cvap_benefitsrequestedother = model.ExpenseInformation.otherSpecificExpenses; // Build Benefits CSV String string tempBenefits = ""; if (model.ExpenseInformation.haveDisabilityPlanBenefits) { tempBenefits = tempBenefits + "100000000,"; } if (model.ExpenseInformation.haveEmploymentInsuranceBenefits) { tempBenefits = tempBenefits + "100000001,"; } if (model.ExpenseInformation.haveIncomeAssistanceBenefits) { tempBenefits = tempBenefits + "100000002,"; } if (model.ExpenseInformation.haveCanadaPensionPlanBenefits) { tempBenefits = tempBenefits + "100000003,"; } if (model.ExpenseInformation.haveAboriginalAffairsAndNorthernDevelopmentCanadaBenefits) { tempBenefits = tempBenefits + "100000004,"; } if (model.ExpenseInformation.haveCivilActionBenefits) { tempBenefits = tempBenefits + "100000005,"; } if (model.ExpenseInformation.haveOtherBenefits) { tempBenefits = tempBenefits + "100000006,"; } if (tempBenefits.Length > 0) { tempBenefits = tempBenefits.Substring(0, tempBenefits.Length - 1); application.Application.vsd_cvap_otherbenefits = tempBenefits; } application.Application.vsd_cvap_otherbenefitsother = model.ExpenseInformation.otherSpecificBenefits; } if (model.EmploymentIncomeInformation != null) { // what is with all the "ifm" stuff? if (model.EmploymentIncomeInformation.wereYouEmployedAtTimeOfCrime.HasValue) { application.Application.vsd_cvap_ifmemployedduringcrime = model.EmploymentIncomeInformation.wereYouEmployedAtTimeOfCrime; } application.Application.vsd_cvap_ifmatworkduringcrime = model.EmploymentIncomeInformation.wereYouAtWorkAtTimeOfIncident; application.Application.vsd_cvap_ifmwcbclaimnumber = model.EmploymentIncomeInformation.workersCompensationClaimNumber; application.Application.vsd_cvap_ifmmissedwork = model.EmploymentIncomeInformation.didYouMissWorkDueToCrime; if (model.EmploymentIncomeInformation.daysWorkMissedStart.HasValue) { application.Application.vsd_cvap_ifmmissedworkstart = model.EmploymentIncomeInformation.daysWorkMissedStart; } if (model.EmploymentIncomeInformation.daysWorkMissedEnd.HasValue) { application.Application.vsd_cvap_ifmmissedworkend = model.EmploymentIncomeInformation.daysWorkMissedEnd; } application.Application.vsd_cvap_ifmlostwages = model.EmploymentIncomeInformation.didYouLoseWages; if (model.EmploymentIncomeInformation.areYouSelfEmployed > 0) { application.Application.vsd_cvap_ifmselfemployed = model.EmploymentIncomeInformation.areYouSelfEmployed; } application.Application.vsd_cvap_ifmcontactemployer = model.EmploymentIncomeInformation.mayContactEmployer; } if (model.RepresentativeInformation != null) { application.Application.vsd_cvap_onbehalfofdeclaration = model.RepresentativeInformation.completingOnBehalfOf; } if (model.DeclarationInformation != null) { // TODO: Apparently we don't do anything with this information? No obvious fields on the Dynamics side to feed this into } if (model.AuthorizationInformation != null) { application.Application.vsd_cvap_onbehalfofdeclaration = model.RepresentativeInformation.completingOnBehalfOf; application.Application.vsd_authorizationsignature = model.AuthorizationInformation.signature; } application.Application.vsd_applicantssignature = model.AuthorizationInformation.signature; // TODO: where does this come from? //application.Application.vsd_cvap_optionalauthorization = 0; // TODO: where does this come from? //application.Application.vsd_optionalauthorizationsignature = ""; // TODO: where does this come from? //application.DocumentCollection = new Documentcollection[1]; // TODO: bind collection return(application); }
private static async Task <string> CreateCaseActionOld(IConfiguration configuration, ApplicationFormModel model) { HttpClient httpClient = null; try { string dynamicsOdataUri = configuration["DYNAMICS_ODATAURI"]; string aadTenantId = configuration["DYNAMICS_AADTENTANTID"]; string serverAppIdUri = configuration["DYNAMICS_SERVERAPPIDURI"]; string clientKey = configuration["DYNAMICS_CLIENTKEY"]; string clientId = configuration["DYNAMICS_CLIENTID"]; string ssgUsername = ""; string ssgPassword = ""; AuthenticationResult authenticationResult = null; // authenticate using ADFS. if (string.IsNullOrEmpty(ssgUsername) || string.IsNullOrEmpty(ssgPassword)) { var authenticationContext = new AuthenticationContext($"https://login.windows.net/{aadTenantId}"); var clientCredential = new ClientCredential(clientId, clientKey); var task = authenticationContext.AcquireTokenAsync(serverAppIdUri, clientCredential); task.Wait(); authenticationResult = task.Result; } var application = model.ToVsdVictimsModel(); var applicationJson = JsonConvert.SerializeObject(application); httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authenticationResult.AccessToken); httpClient.BaseAddress = new Uri(string.Join("/", dynamicsOdataUri, "vsd_CreateCVAPClaim")); httpClient.Timeout = new TimeSpan(1, 0, 0); // 1 hour timeout httpClient.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0"); httpClient.DefaultRequestHeaders.Add("OData-Version", "4.0"); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "vsd_CreateCVAPClaim"); request.Content = new StringContent(applicationJson, Encoding.UTF8, "application/json"); HttpResponseMessage response = await httpClient.SendAsync(request); if (response.StatusCode == HttpStatusCode.OK) { var jsonResult = response.Content.ReadAsStringAsync().Result; return(jsonResult); } return(response.Content.ReadAsStringAsync().Result); //return response; } finally { if (httpClient != null) { httpClient.Dispose(); } } }
private static async Task <string> CreateCaseAction(IConfiguration configuration, ApplicationFormModel model) { HttpClient httpClient = null; try { var application = model.ToVsdVictimsModel(); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; var applicationJson = JsonConvert.SerializeObject(application, settings); applicationJson = applicationJson.Replace("odatatype", "@odata.type"); // Get results into the tuple var endpointAction = "vsd_CreateCVAPClaim"; var tuple = await GetDynamicsHttpClientNew(configuration, applicationJson, endpointAction); string tempResult = tuple.Item1.ToString(); DynamicsResponse dynamicsResponse = new DynamicsResponse(); dynamicsResponse.IsSuccess = (tempResult == "200"); // Only return true if we get a 200 back from the server dynamicsResponse.Result = tempResult; dynamicsResponse.odatacontext = tuple.Item2.ToString(); return(dynamicsResponse.odatacontext); } finally { if (httpClient != null) { httpClient.Dispose(); } } }