public void Register(Register register) { CRMConnection con = new CRMConnection(); try { con.connection(); if (con.organizationService != null) { Guid userid = ((WhoAmIResponse)con.organizationService.Execute(new WhoAmIRequest())).UserId; if (userid != Guid.Empty) { var Register = new Entity("new_applicantionusers"); Register["new_name"] = register.Firstname; Register["new_lastname"] = register.Lastname; Register["new_email"] = register.Email; Register["new_username"] = register.Username; Register["new_password"] = register.Password; //Create the user Guid regid = con.organizationService.Create(Register); } } } catch (Exception ex) { throw ex; } }
public void GetStatus(Applicant applicant) { try { con.connection(); if (con.organizationService != null) { Guid userid = ((WhoAmIResponse)con.organizationService.Execute(new WhoAmIRequest())).UserId; if (userid != Guid.Empty) { QueryByAttribute query = new QueryByAttribute("new_applicant"); query.ColumnSet = new ColumnSet(true); query.Attributes.AddRange("new_id"); query.Values.AddRange(applicant.Id); EntityCollection accountRecord = con.organizationService.RetrieveMultiple(query); //if (applicant.ApplicationType == "Dealer") // { // Applicant["new_applicationtype"] = new OptionSetValue(100000000); // Applicant["new_expirationdate"] = applicant.ExpirationDate; // Applicant["new_previousdealerlicensedate"] = applicant.PreviousDealerDate; // } // else // { // Applicant["new_applicationtype"] = new OptionSetValue(100000001); // } var appstatus = ((OptionSetValue)accountRecord[0]["new_applicationstatus"]).Value; if (appstatus == 100000000) { applicant.Appstatus = "new"; } else if (appstatus == 100000001) { applicant.Appstatus = "Approved"; } else if (appstatus == 100000002) { applicant.Appstatus = "Denied"; } } } } catch (Exception ex) { throw ex; } }
public void logindetails(Login login) { try { con.connection(); if (con.organizationService != null) { Guid userid = ((WhoAmIResponse)con.organizationService.Execute(new WhoAmIRequest())).UserId; if (userid != Guid.Empty) { QueryByAttribute query = new QueryByAttribute("new_applicantionusers"); { query.ColumnSet = new ColumnSet("new_applicantionusersid"); query.Attributes.AddRange("new_username", "new_password"); query.Values.AddRange(login.Username, login.Password); }; EntityCollection accountRecord = con.organizationService.RetrieveMultiple(query); if (accountRecord != null && accountRecord.Entities.Count > 0) { login.LoginStatus = "Login Success"; login.Userid = (Guid)accountRecord[0]["new_applicantionusersid"]; } else { login.LoginStatus = "Login Failed"; } } } } catch (Exception ex) { throw ex; } }
public void UpdateRecords(Applicant applicant) { CRMConnection con = new CRMConnection(); bool gender = false; bool condition = false; try { con.connection(); if (con.organizationService != null) { Guid userid = ((WhoAmIResponse)con.organizationService.Execute(new WhoAmIRequest())).UserId; if (userid != Guid.Empty) { //retrieve applicant Guid QueryByAttribute query = new QueryByAttribute("new_applicant"); query.ColumnSet = new ColumnSet(true); query.Attributes.AddRange("new_id"); query.Values.AddRange(applicant.Id); EntityCollection accountRecord = con.organizationService.RetrieveMultiple(query); Guid guid = (Guid)accountRecord[0]["new_applicantid"]; //Update Applicant var Applicant = new Entity("new_applicant"); Applicant.Id = guid; if (applicant.ApplicationType == "Dealer") { Applicant["new_applicationtype"] = new OptionSetValue(100000000); Applicant["new_expirationdate"] = applicant.ExpirationDate; Applicant["new_previousdealerlicensedate"] = applicant.PreviousDealerDate; Applicant["new_driverlicenseidnumber"] = applicant.Identificationnumber; Applicant["new_dealeraddress"] = applicant.DealerAddress; OptionSetValueCollection MultiOptionSet = new OptionSetValueCollection(); if (applicant.Pistols) { MultiOptionSet.Add(new OptionSetValue(100000000)); } if (applicant.Firearms) { MultiOptionSet.Add(new OptionSetValue(100000001)); } if (applicant.Ammunition) { MultiOptionSet.Add(new OptionSetValue(100000002)); } Applicant["new_intendtodeal"] = new OptionSetValueCollection(MultiOptionSet); } else if (applicant.ApplicationType == "Alien") { Applicant["new_applicationtype"] = new OptionSetValue(100000001); Applicant["new_address"] = applicant.DealerAddress; Applicant["new_driverlicenseidnumber"] = applicant.DriverLicenseNumber; } else if (applicant.ApplicationType == "FTA") { Applicant["new_applicationtype"] = new OptionSetValue(100000003); Applicant["new_expirationdate"] = applicant.ExpirationDate; Applicant["new_dealeraddress"] = applicant.DealerAddress; Applicant["new_dealeremail"] = applicant.Email; Applicant["new_dateweapondelivered"] = applicant.weapondelivereddate; Applicant["new_applicationinitiated"] = applicant.ApplicationDate; if (applicant.Firearms) { Applicant["new_ftaapplicationtype"] = new OptionSetValue(100000000); } else if (applicant.Pistols) { Applicant["new_ftaapplicationtype"] = new OptionSetValue(100000001); } } Applicant["new_applicationstatus"] = new OptionSetValue(100000000); Applicant["new_dealercompanyname"] = applicant.Companyname; Applicant["new_mailingcity"] = applicant.DealerCity; Applicant["new_mailingstate"] = applicant.DealerState; Applicant["new_mailingzipcode"] = applicant.DealerZipcode; Applicant["new_mailingcountry"] = applicant.DealerCountry; Applicant["new_dealerareacode"] = applicant.DealerAreaCode; Applicant["new_federalfirearmslicensenumber"] = applicant.firearmslicensenumber; Applicant["new_ubinumber"] = applicant.UBInumber; Applicant["new_identificationtype"] = applicant.Identificationtype; Applicant["new_name"] = applicant.Fullname; Applicant["new_aliasname"] = applicant.Aliasname; Applicant["new_city"] = applicant.City; Applicant["new_state"] = applicant.State; Applicant["new_zipcode"] = applicant.Zipcode; Applicant["new_country"] = applicant.Country; Applicant["new_address"] = applicant.Address; Applicant["new_race"] = applicant.Race; Applicant["new_tatoos"] = applicant.Tatoos; if (applicant.Gender == "Female") { gender = false; } else { gender = true; } Applicant["new_gender"] = gender; Applicant["new_height"] = applicant.Height; Applicant["new_weight"] = applicant.Weight; Applicant["new_eyes"] = applicant.Eyes; Applicant["new_hair"] = applicant.Hair; Applicant["new_areacode"] = applicant.Areacode; Applicant["new_birthplace"] = applicant.Placeofbirth; Applicant["new_dob"] = applicant.DOB; Applicant["new_email"] = applicant.Email; Applicant["new_alienregistrationnumber"] = applicant.AlienRegistrationnumber; Applicant["new_passportnumber"] = applicant.PassportNumber; Applicant["new_visanumber"] = applicant.VisaNumber; Applicant["new_privatetransfer"] = applicant.PrivateTransfer; Applicant["new_approvalcode"] = applicant.Approvalcode; Applicant["new_appropriatelea"] = applicant.AppropriateLea; Applicant["new_others"] = applicant.Others; Applicant["new_dealertransaction"] = applicant.Dealertransaction; Applicant["new_caliber"] = applicant.Caliber; Applicant["new_barrellength"] = applicant.Barrellength; if (applicant.condition == "New") { condition = false; } else if (applicant.condition == "Used") { condition = true; } Applicant["new_condition"] = condition; Applicant["new_modelnumberorname"] = applicant.Modelno; Applicant["new_businessid"] = applicant.businessId; Applicant["new_locationid"] = applicant.LocationId; Applicant["new_dealerstorename"] = applicant.storename; Applicant["new_permanentresidentcardnumber"] = applicant.residentcardno; Applicant["new_alienfirearmslicensenumber"] = applicant.washintonfirearmnumber; Applicant["new_cplnumber"] = applicant.Concealedlicensenumber; Applicant["new_issuingauthority"] = applicant.issuingauthority; Applicant["new_firearmserialnumber"] = applicant.FireArmSerialnumber; //Update the application con.organizationService.Update(Applicant); if (applicant.ApplicationType != "FTA") { //update Question answers var Qansr = new Entity("new_applicantquestionanswers"); QueryByAttribute qnsquery = new QueryByAttribute("new_applicantquestionanswers"); qnsquery.ColumnSet = new ColumnSet(true); qnsquery.Attributes.AddRange("new_applicant"); qnsquery.Values.AddRange(guid); EntityCollection qnsRecord = con.organizationService.RetrieveMultiple(qnsquery); if (qnsRecord != null && qnsRecord.Entities.Count > 0) { for (int i = 0; i < qnsRecord.Entities.Count; i++) { Qansr.Id = (Guid)qnsRecord[i]["new_applicantquestionanswersid"]; EntityReference entref = (EntityReference)qnsRecord[i].Attributes["new_question"]; if (entref.Name == "Q1") { if ((applicant.Question1Yes == false && applicant.Question1No == false) || (applicant.Question1No == true)) { Qansr["new_answer"] = false; } else if (applicant.Question1Yes == true) { Qansr["new_answer"] = true; } con.organizationService.Update(Qansr); } if (entref.Name == "Q2") { if ((applicant.Question2Yes == false && applicant.Question2No == false) || (applicant.Question2No == true)) { Qansr["new_answer"] = false; } else if (applicant.Question2Yes == true) { Qansr["new_answer"] = true; } con.organizationService.Update(Qansr); } if (entref.Name == "Q3") { if ((applicant.Question3Yes == false && applicant.Question3No == false) || (applicant.Question3No == true)) { Qansr["new_answer"] = false; } else if (applicant.Question3Yes == true) { Qansr["new_answer"] = true; } con.organizationService.Update(Qansr); } if (entref.Name == "Q4") { if ((applicant.Question4Yes == false && applicant.Question4No == false) || (applicant.Question4No == true)) { Qansr["new_answer"] = false; } else if (applicant.Question4Yes == true) { Qansr["new_answer"] = true; } con.organizationService.Update(Qansr); } if (entref.Name == "Q5") { if ((applicant.Question5Yes == false && applicant.Question5No == false) || (applicant.Question5No == true)) { Qansr["new_answer"] = false; } else if (applicant.Question5Yes == true) { Qansr["new_answer"] = true; } con.organizationService.Update(Qansr); } if (entref.Name == "Q6") { if ((applicant.Question6Yes == false && applicant.Question6No == false) || (applicant.Question6No == true)) { Qansr["new_answer"] = false; } else if (applicant.Question6Yes == true) { Qansr["new_answer"] = true; } con.organizationService.Update(Qansr); } if (entref.Name == "Q7") { if ((applicant.Question7Yes == false && applicant.Question7No == false) || (applicant.Question7No == true)) { Qansr["new_answer"] = false; } else if (applicant.Question7Yes == true) { Qansr["new_answer"] = true; } con.organizationService.Update(Qansr); } if (entref.Name == "Q8") { if ((applicant.Question8Yes == false && applicant.Question8No == false) || (applicant.Question8No == true)) { Qansr["new_answer"] = false; } else if (applicant.Question8Yes == true) { Qansr["new_answer"] = true; } con.organizationService.Update(Qansr); } if (entref.Name == "Q9") { if ((applicant.Question9Yes == false && applicant.Question9No == false) || (applicant.Question9No == true)) { Qansr["new_answer"] = false; } else if (applicant.Question9Yes == true) { Qansr["new_answer"] = true; } con.organizationService.Update(Qansr); } if (entref.Name == "Q10") { if ((applicant.Question10Yes == false && applicant.Question8No == false) || (applicant.Question10No == true)) { Qansr["new_answer"] = false; } else if (applicant.Question10Yes == true) { Qansr["new_answer"] = true; } con.organizationService.Update(Qansr); } if (entref.Name == "Q11") { if ((applicant.Question11Yes == false && applicant.Question11No == false) || (applicant.Question11No == true)) { Qansr["new_answer"] = false; } else if (applicant.Question11Yes == true) { Qansr["new_answer"] = true; } con.organizationService.Update(Qansr); } } } } } } else { //Console.WriteLine("Failed to Established Connection!!!"); } } catch (Exception ex) { throw ex; } }
public void Getrecord(Applicant applicant) { try { con.connection(); if (con.organizationService != null) { Guid userid = ((WhoAmIResponse)con.organizationService.Execute(new WhoAmIRequest())).UserId; if (userid != Guid.Empty) { QueryByAttribute query = new QueryByAttribute("new_applicant"); query.ColumnSet = new ColumnSet(true); query.Attributes.AddRange("new_id"); query.Values.AddRange(applicant.Id); EntityCollection applicantRecord = con.organizationService.RetrieveMultiple(query); if (applicantRecord != null && applicantRecord.Entities.Count > 0) { if (applicantRecord[0].Contains("new_applicantid") && applicantRecord[0]["new_applicantid"] != null) { applicant.ApplicantID = (Guid)applicantRecord[0]["new_applicantid"]; } if (applicantRecord[0].Contains("new_applicationtype") && applicantRecord[0]["new_applicationtype"] != null) { var apptype = ((OptionSetValue)applicantRecord[0]["new_applicationtype"]).Value; if (apptype == 100000000) { applicant.ApplicationType = "Dealer"; } else if (apptype == 100000001) { applicant.ApplicationType = "Alien"; } else if (apptype == 100000003) { applicant.ApplicationType = "FTA"; } } object FieldObj; if (applicantRecord[0].Attributes.TryGetValue("new_intendtodeal", out FieldObj)) { //Get the collection of value(s) for MultiSelect Option Set field OptionSetValueCollection Field = (OptionSetValueCollection)FieldObj; if (Field.Count > 0) { for (int i = 0; i < Field.Count; i++) { if (Field[i].Value == 100000000) { applicant.Pistols = true; } if (Field[i].Value == 100000001) { applicant.Firearms = true; } if (Field[i].Value == 100000002) { applicant.Ammunition = true; } } } } if (applicantRecord[0].Contains("new_dealercompanyname") && applicantRecord[0]["new_dealercompanyname"] != null) { applicant.Companyname = applicantRecord[0]["new_dealercompanyname"].ToString(); } if (applicantRecord[0].Contains("new_tatoos") && applicantRecord[0]["new_tatoos"] != null) { applicant.Tatoos = applicantRecord[0]["new_tatoos"].ToString(); } if (applicantRecord[0].Contains("new_dealeraddress") && applicantRecord[0]["new_dealeraddress"] != null) { applicant.DealerAddress = applicantRecord[0]["new_dealeraddress"].ToString(); } if (applicant.ApplicationType == "Alien") { if (applicantRecord[0].Contains("new_address") && applicantRecord[0]["new_address"] != null) { applicant.DealerAddress = applicantRecord[0]["new_address"].ToString(); } } if (applicantRecord[0].Contains("new_mailingcity") && applicantRecord[0]["new_mailingcity"] != null) { applicant.DealerCity = applicantRecord[0]["new_mailingcity"].ToString(); } if (applicantRecord[0].Contains("new_mailingstate") && applicantRecord[0]["new_mailingstate"] != null) { applicant.DealerState = applicantRecord[0]["new_mailingstate"].ToString(); } if (applicantRecord[0].Contains("new_mailingzipcode") && applicantRecord[0]["new_mailingzipcode"] != null) { applicant.DealerZipcode = applicantRecord[0]["new_mailingzipcode"].ToString(); } if (applicantRecord[0].Contains("new_mailingcountry") && applicantRecord[0]["new_mailingcountry"] != null) { applicant.DealerCountry = applicantRecord[0]["new_mailingcountry"].ToString(); } if (applicantRecord[0].Contains("new_dealerareacode") && applicantRecord[0]["new_dealerareacode"] != null) { applicant.DealerAreaCode = applicantRecord[0]["new_dealerareacode"].ToString(); } if (applicantRecord[0].Contains("new_federalfirearmslicensenumber") && applicantRecord[0]["new_federalfirearmslicensenumber"] != null) { applicant.firearmslicensenumber = applicantRecord[0]["new_federalfirearmslicensenumber"].ToString(); } if (applicantRecord[0].Contains("new_expirationdate") && applicantRecord[0]["new_expirationdate"] != null) { applicant.ExpirationDate = (DateTime)applicantRecord[0]["new_expirationdate"]; } if (applicantRecord[0].Contains("new_ubinumber") && applicantRecord[0]["new_ubinumber"] != null) { applicant.UBInumber = applicantRecord[0]["new_ubinumber"].ToString(); } if (applicantRecord[0].Contains("new_previousdealerlicensedate") && applicantRecord[0]["new_previousdealerlicensedate"] != null) { applicant.PreviousDealerDate = (DateTime)applicantRecord[0]["new_previousdealerlicensedate"]; } if (applicantRecord[0].Contains("new_identificationtype") && applicantRecord[0]["new_identificationtype"] != null) { applicant.Identificationtype = applicantRecord[0]["new_identificationtype"].ToString(); } if (applicantRecord[0].Contains("new_driverlicenseidnumber") && applicantRecord[0]["new_driverlicenseidnumber"] != null) { applicant.Identificationnumber = applicantRecord[0]["new_driverlicenseidnumber"].ToString(); } if (applicantRecord[0].Contains("new_name") && applicantRecord[0]["new_name"] != null) { applicant.Fullname = applicantRecord[0]["new_name"].ToString(); } if (applicantRecord[0].Contains("new_aliasname") && applicantRecord[0]["new_aliasname"] != null) { applicant.Aliasname = applicantRecord[0]["new_aliasname"].ToString(); } if (applicantRecord[0].Contains("new_city") && applicantRecord[0]["new_city"] != null) { applicant.City = applicantRecord[0]["new_city"].ToString(); } if (applicantRecord[0].Contains("new_state") && applicantRecord[0]["new_state"] != null) { applicant.State = applicantRecord[0]["new_state"].ToString(); } if (applicantRecord[0].Contains("new_zipcode") && applicantRecord[0]["new_zipcode"] != null) { applicant.Zipcode = applicantRecord[0]["new_zipcode"].ToString(); } if (applicantRecord[0].Contains("new_country") && applicantRecord[0]["new_country"] != null) { applicant.Country = applicantRecord[0]["new_country"].ToString(); } if (applicantRecord[0].Contains("new_address") && applicantRecord[0]["new_address"] != null) { applicant.Address = applicantRecord[0]["new_address"].ToString(); } if (applicantRecord[0].Contains("new_race") && applicantRecord[0]["new_race"] != null) { applicant.Race = applicantRecord[0]["new_race"].ToString(); } if (applicantRecord[0].Contains("new_gender") && applicantRecord[0]["new_gender"] != null) { var gender = applicantRecord[0].Contains("new_gender").ToString(); if (gender == "True") { applicant.Gender = "Male"; } else if (gender == "False") { applicant.Gender = "Female"; } //applicant.Gender = applicantRecord[0]["new_gender"].ToString(); } if (applicantRecord[0].Contains("new_height") && applicantRecord[0]["new_height"] != null) { applicant.Height = applicantRecord[0]["new_height"].ToString(); } if (applicantRecord[0].Contains("new_weight") && applicantRecord[0]["new_weight"] != null) { applicant.Weight = applicantRecord[0]["new_weight"].ToString(); } if (applicantRecord[0].Contains("new_eyes") && applicantRecord[0]["new_eyes"] != null) { applicant.Eyes = applicantRecord[0]["new_eyes"].ToString(); } if (applicantRecord[0].Contains("new_hair") && applicantRecord[0]["new_hair"] != null) { applicant.Hair = applicantRecord[0]["new_hair"].ToString(); } if (applicantRecord[0].Contains("new_areacode") && applicantRecord[0]["new_areacode"] != null) { applicant.Areacode = applicantRecord[0]["new_areacode"].ToString(); } if (applicantRecord[0].Contains("new_birthplace") && applicantRecord[0]["new_birthplace"] != null) { applicant.Placeofbirth = applicantRecord[0]["new_birthplace"].ToString(); } if (applicantRecord[0].Contains("new_dob") && applicantRecord[0]["new_dob"] != null) { applicant.DOB = (DateTime)applicantRecord[0]["new_dob"]; } if (applicantRecord[0].Contains("new_email") && applicantRecord[0]["new_email"] != null) { applicant.Email = applicantRecord[0]["new_email"].ToString(); } if (applicantRecord[0].Contains("new_driverlicenseidnumber") && applicantRecord[0]["new_driverlicenseidnumber"] != null) { applicant.DriverLicenseNumber = applicantRecord[0]["new_driverlicenseidnumber"].ToString(); } if (applicantRecord[0].Contains("new_alienregistrationnumber") && applicantRecord[0]["new_alienregistrationnumber"] != null) { applicant.AlienRegistrationnumber = applicantRecord[0]["new_alienregistrationnumber"].ToString(); } if (applicantRecord[0].Contains("new_passportnumber") && applicantRecord[0]["new_passportnumber"] != null) { applicant.PassportNumber = applicantRecord[0]["new_passportnumber"].ToString(); } if (applicantRecord[0].Contains("new_visanumber") && applicantRecord[0]["new_visanumber"] != null) { applicant.VisaNumber = applicantRecord[0]["new_visanumber"].ToString(); } if (applicantRecord[0].Contains("new_ftaapplicationtype") && applicantRecord[0]["new_ftaapplicationtype"] != null) { var ftatype = ((OptionSetValue)applicantRecord[0]["new_ftaapplicationtype"]).Value; if (ftatype == 100000000) { applicant.Firearms = true; } if (ftatype == 100000001) { applicant.Pistols = true; } } if (applicantRecord[0].Contains("new_approvalcode") && applicantRecord[0]["new_approvalcode"] != null) { applicant.Approvalcode = applicantRecord[0]["new_approvalcode"].ToString(); } if (applicantRecord[0].Contains("new_dealertransaction") && applicantRecord[0]["new_dealertransaction"] != null) { applicant.Dealertransaction = applicantRecord[0]["new_dealertransaction"].ToString(); } if (applicantRecord[0].Contains("new_caliber") && applicantRecord[0]["new_caliber"] != null) { applicant.Caliber = applicantRecord[0]["new_caliber"].ToString(); } if (applicantRecord[0].Contains("new_barrellength") && applicantRecord[0]["new_barrellength"] != null) { applicant.Barrellength = applicantRecord[0]["new_barrellength"].ToString(); } if (applicantRecord[0].Contains("new_condition") && applicantRecord[0]["new_condition"] != null) { var condition = applicantRecord[0].Contains("new_condition").ToString(); if (condition == "True") { applicant.condition = "New"; } else if (condition == "False") { applicant.condition = "Used"; } } if (applicantRecord[0].Contains("new_modelnumberorname") && applicantRecord[0]["new_modelnumberorname"] != null) { applicant.Modelno = applicantRecord[0]["new_modelnumberorname"].ToString(); } if (applicantRecord[0].Contains("new_dateweapondelivered") && applicantRecord[0]["new_dateweapondelivered"] != null) { applicant.weapondelivereddate = (DateTime)applicantRecord[0]["new_dateweapondelivered"]; } if (applicantRecord[0].Contains("new_businessid") && applicantRecord[0]["new_businessid"] != null) { applicant.businessId = applicantRecord[0]["new_businessid"].ToString(); } if (applicantRecord[0].Contains("new_locationid") && applicantRecord[0]["new_locationid"] != null) { applicant.LocationId = applicantRecord[0]["new_locationid"].ToString(); } if (applicantRecord[0].Contains("new_dealerstorename") && applicantRecord[0]["new_dealerstorename"] != null) { applicant.storename = applicantRecord[0]["new_dealerstorename"].ToString(); } if (applicantRecord[0].Contains("new_permanentresidentcardnumber") && applicantRecord[0]["new_permanentresidentcardnumber"] != null) { applicant.residentcardno = applicantRecord[0]["new_permanentresidentcardnumber"].ToString(); } if (applicantRecord[0].Contains("new_alienfirearmslicensenumber") && applicantRecord[0]["new_alienfirearmslicensenumber"] != null) { applicant.washintonfirearmnumber = applicantRecord[0]["new_alienfirearmslicensenumber"].ToString(); } if (applicantRecord[0].Contains("new_cplnumber") && applicantRecord[0]["new_cplnumber"] != null) { applicant.Concealedlicensenumber = applicantRecord[0]["new_cplnumber"].ToString(); } if (applicantRecord[0].Contains("new_issuingauthority") && applicantRecord[0]["new_issuingauthority"] != null) { applicant.issuingauthority = applicantRecord[0]["new_issuingauthority"].ToString(); } if (applicantRecord[0].Contains("new_applicationinitiated") && applicantRecord[0]["new_applicationinitiated"] != null) { applicant.ApplicationDate = (DateTime)applicantRecord[0]["new_applicationinitiated"]; } if (applicantRecord[0].Contains("new_firearmserialnumber") && applicantRecord[0]["new_firearmserialnumber"] != null) { applicant.FireArmSerialnumber = applicantRecord[0]["new_firearmserialnumber"].ToString(); } if (applicantRecord[0].Contains("new_privatetransfer") && applicantRecord[0]["new_privatetransfer"] != null) { applicant.PrivateTransfer = (bool)applicantRecord[0]["new_privatetransfer"]; } if (applicantRecord[0].Contains("new_others") && applicantRecord[0]["new_others"] != null) { applicant.Others = applicantRecord[0]["new_others"].ToString(); } if (applicantRecord[0].Contains("new_appropriatelea") && applicantRecord[0]["new_appropriatelea"] != null) { applicant.AppropriateLea = applicantRecord[0]["new_appropriatelea"].ToString(); } if (applicant.ApplicationType != "FTA") { QueryByAttribute qnsquery = new QueryByAttribute("new_applicantquestionanswers"); qnsquery.ColumnSet = new ColumnSet(true); qnsquery.Attributes.AddRange("new_applicant"); qnsquery.Values.AddRange(applicant.ApplicantID); EntityCollection qnsRecord = con.organizationService.RetrieveMultiple(qnsquery); if (qnsRecord != null && qnsRecord.Entities.Count > 0) { for (int i = 0; i < qnsRecord.Entities.Count; i++) { if (qnsRecord[i].Contains("new_question") && qnsRecord[i]["new_question"] != null) { EntityReference entref = (EntityReference)qnsRecord[i].Attributes["new_question"]; if (entref.Name == "Q1") { if (qnsRecord[i].Contains("new_answer") && qnsRecord[i]["new_answer"] != null) { if ((bool)qnsRecord[i]["new_answer"] == true) { applicant.Question1Yes = true; } else { applicant.Question1No = true; } } } if (entref.Name == "Q2") { if (qnsRecord[i].Contains("new_answer") && qnsRecord[i]["new_answer"] != null) { if ((bool)qnsRecord[i]["new_answer"] == true) { applicant.Question2Yes = true; } else { applicant.Question2No = true; } } } if (entref.Name == "Q3") { if (qnsRecord[i].Contains("new_answer") && qnsRecord[i]["new_answer"] != null) { if ((bool)qnsRecord[i]["new_answer"] == true) { applicant.Question3Yes = true; } else { applicant.Question3No = true; } } } if (entref.Name == "Q4") { if (qnsRecord[i].Contains("new_answer") && qnsRecord[i]["new_answer"] != null) { if ((bool)qnsRecord[i]["new_answer"] == true) { applicant.Question4Yes = true; } else { applicant.Question4No = true; } } } if (entref.Name == "Q5") { if (qnsRecord[i].Contains("new_answer") && qnsRecord[i]["new_answer"] != null) { if ((bool)qnsRecord[i]["new_answer"] == true) { applicant.Question5Yes = true; } else { applicant.Question5No = true; } } } if (entref.Name == "Q6") { if (qnsRecord[i].Contains("new_answer") && qnsRecord[i]["new_answer"] != null) { if ((bool)qnsRecord[i]["new_answer"] == true) { applicant.Question6Yes = true; } else { applicant.Question6No = true; } } } if (entref.Name == "Q7") { if (qnsRecord[i].Contains("new_answer") && qnsRecord[i]["new_answer"] != null) { if ((bool)qnsRecord[i]["new_answer"] == true) { applicant.Question7Yes = true; } else { applicant.Question7No = true; } } } if (entref.Name == "Q8") { if (qnsRecord[i].Contains("new_answer") && qnsRecord[i]["new_answer"] != null) { if ((bool)qnsRecord[i]["new_answer"] == true) { applicant.Question8Yes = true; } else { applicant.Question8No = true; } } } if (entref.Name == "Q9") { if (qnsRecord[i].Contains("new_answer") && qnsRecord[i]["new_answer"] != null) { if ((bool)qnsRecord[i]["new_answer"] == true) { applicant.Question9Yes = true; } else { applicant.Question9No = true; } } } if (entref.Name == "Q10") { if (qnsRecord[i].Contains("new_answer") && qnsRecord[i]["new_answer"] != null) { if ((bool)qnsRecord[i]["new_answer"] == true) { applicant.Question10Yes = true; } else { applicant.Question10No = true; } } } if (entref.Name == "Q11") { if (qnsRecord[i].Contains("new_answer") && qnsRecord[i]["new_answer"] != null) { if ((bool)qnsRecord[i]["new_answer"] == true) { applicant.Question11Yes = true; } else { applicant.Question11No = true; } } } } } } } } } } } catch (Exception ex) { throw ex; } }