/// <summary> /// this method will update permit applicant /// </summary> /// <param name="model"></param> /// <returns></returns> public PermitApplicant UpdatePermitApplicant(PermitApplicant model) { try { var permitApplicant = context.PermitApplicant.Where(x => x.ApplicantID.Equals(model.ApplicantID)).FirstOrDefault(); if (permitApplicant != null) { permitApplicant.ApplicantType = model.ApplicantType; permitApplicant.Name = model.Name; permitApplicant.Contact = model.Contact; permitApplicant.Address = model.Address; permitApplicant.City = model.City; permitApplicant.State = model.State; permitApplicant.Zip = model.Zip; permitApplicant.PhoneNumber = model.PhoneNumber; permitApplicant.Email = model.Email; permitApplicant.PermitID = model.PermitID; context.SaveChanges(); model = permitApplicant; } } catch (Exception ex) { model = null; } return(model); }
void SendApplicantInfo(PermitApplicant applicant) { if (applicant != null) { Messenger.Default.Send <MessageCommunicator>(new MessageCommunicator() { ApplicantInfo = applicant }); } }
public PermitApplicant UpdatePermitApplicant(PermitApplicant model) { try { model = permitLogic.UpdatePermitApplicant(model); } catch (Exception) { model = null; } return(model); }
/// <summary> /// this method will create applicant towards a permit /// </summary> /// <param name="model"></param> /// <returns></returns> public PermitApplicant InsertPermitApplicant(PermitApplicant model) { try { model.CreatedDate = DateTime.Now; context.PermitApplicant.Add(model); context.SaveChanges(); } catch (Exception ex) { model = null; } return(model); }
async void ContractorSelect() { if (ContractorList.Count > 0) { var contractor = await _dataService.GetContractor(SelectedContractor.Split(',')[0]); PermitInfo.ContractorID = SelectedContractor.Split(',')[1].ToString(); PermitApplicant applicant = new PermitApplicant(); applicant.ApplicantType = "Contractor"; CCBNumber = contractor.license_number; applicant.Name = (!string.IsNullOrEmpty(contractor.alias_name) ? contractor.alias_name : contractor.business_name); applicant.Contact = contractor.rmi_name; applicant.Address = contractor.address; applicant.City = contractor.city; applicant.State = contractor.state; applicant.Zip = contractor.zip; applicant.PhoneNumber = contractor.business_telephone; ApplicantInfo = applicant; ContractorList.Clear(); SearchKeyword = string.Empty; } }
async void SubmitApplication() { if ((bool)chkLegal.IsChecked) { Permit isExistingPermit; //Permit isExistingPermitByAddress; //try //{ if ((bool)rdoAffidavit.IsChecked) { var isExistingPermitByAffidavit = await _dataService.GetPermitByAffidavit(long.Parse(txtAffidavitSearch.Text)); isExistingPermit = isExistingPermitByAffidavit; } else { var isExistingPermitByAddress = await _dataService.GetPermitByAffidavit(long.Parse(txtAffidavitSearch.Text)); isExistingPermit = isExistingPermitByAddress; } if (isExistingPermit == null) //if (isExistingPermit == null || (!(isExistingPermit.PermitStatus== Constants.PermitStatus_Submitted) || !(isExistingPermit.PermitStatus == Constants.PermitStatus_Accepted))) { Permit model = new Permit(); AffidavitCart cartItem = new AffidavitCart(); //Insert applicant type PermitApplicant applicant = new PermitApplicant(); if ((bool)rdoContractor.IsChecked) { model.ApplicantType = "Contractor"; applicant.ApplicantType = "Contractor"; } else if ((bool)rdoOwner.IsChecked) { model.ApplicantType = "Owner"; applicant.ApplicantType = "Owner"; } else if ((bool)rdoOther.IsChecked) { model.ApplicantType = "Other"; applicant.ApplicantType = "Other"; } applicant.Name = txtContractorName.Text; applicant.Address = txtContractorAddress.Text; applicant.Contact = txtContractorContact.Text; applicant.City = txtContractorCity.Text; applicant.Zip = txtContractorZip.Text; applicant.State = txtContractorState.Text; applicant.PhoneNumber = txtContractorPhone.Text; //applicant.ContactPhoneNumber = txtContractorContactPhone.Text; applicant.PermitID = 0; applicant = await _dataService.InsertPermitApplicant(applicant); //Insert permit if ((bool)rdoAffidavit.IsChecked) { model.AffidavitID = long.Parse(txtAffidavitSearch.Text); model.PropertyAddress = txtPropertySearch.Text; cartItem.AffidavitID = txtAffidavitSearch.Text; cartItem.PropertyAddress = txtPropertySearch.Text; } else { model.AffidavitID = long.Parse(txtAffidavitSearch.Text); model.PropertyAddress = txtPropertySearch.Text; cartItem.AffidavitID = txtAffidavitSearch.Text; cartItem.PropertyAddress = txtPropertySearch.Text; } if (!string.IsNullOrEmpty(txtContractorSearch.Text)) { model.ContractorID = txtContractorSearch.Text.Split(',')[1].ToString(); } else { model.ContractorID = string.Empty; } model.ApplicantID = applicant.ApplicantID; // //model.PermitNo = Aff model.PermitIssued = "No"; model.PermitExtended = "No"; model.BuilderBoardNo = txtCCBNumber.Text; model.DateCancelled = null; model.CancelledBy = string.Empty; model.LastAction = "Application Submitted"; model.DateExpired = DateTime.Parse(txtExpirationDate.Text); if ((bool)rdoContractor.IsChecked) { model.ApplicantType = "Contractor"; } else if ((bool)rdoOwner.IsChecked) { model.ApplicantType = "Owner"; model.ContractorID = "PO"; } else if ((bool)rdoOther.IsChecked) { model.ApplicantType = "Other"; model.ContractorID = "PO"; } model.TotalFee = decimal.Parse(txtFee.Text); model.PermitStatus = Constants.PermitStatus_Submitted; model.SubmissionDate = DateTime.Now; model = await _dataService.InsertPermit(model); applicant.PermitID = model.PermitID; var permitHistory = await _dataService.InsertPermitHistory(model.PermitID, "Submitted", "New permit applied."); applicant = await _dataService.UpdatePermitApplicant(applicant); int permitCount = int.Parse(lblAffidavitCount.Content.ToString()); lblAffidavitCount.Content = permitCount + 1; cartItem.PermitID = model.PermitID.ToString(); cartItem.Remove = "Remove"; cart.Add(cartItem); affidavitGrid.ItemsSource = null; affidavitGrid.ItemsSource = cart; var affidavitFeeList = (List <sw_action_detail>)affidavitFee.ItemsSource; foreach (var item in affidavitFeeList) { var Affidavit = await _dataService.GetAffidavitByNumber(item.aff_no.ToString()); PermitCostsDetail permitCosts = new PermitCostsDetail(); permitCosts.AffidavitID = item.aff_no; permitCosts.Cost = item.cost; permitCosts.CostType = item.action_type; permitCosts.Rate = item.rate; permitCosts.Unit = item.unit; permitCosts.RepairItem = item.action_type; await _dataService.InsertPermitCostsDetail(permitCosts); } MessageBoxResult result = MessageBox.Show("Affidavit submitted successfully. Do you want to apply for another permit?", "Confirmation", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { ClearAffidavit(); chkLegal.IsChecked = false; } else { //if (!Convert.ToBoolean(ConfigurationManager.AppSettings["IsKiosk"].ToString())) //{ // MainWindow window = new MainWindow(); // window.allPermitsOpen(_container); //} //else //{ MainWindow window = new MainWindow(); window.newPermitOpen(_container); //} } } else { MessageBox.Show("This affidavit has a permit pending for approval", "Permit Exist."); } } else { MessageBox.Show("Pls enter the Applicant, Name, Affidavit & agree to statement at the bottom"); } }