public ResponseHdr Post(PostLeadRequest req_lead) { string err = string.Empty; ResponseHdr respHdr = new ResponseHdr(); bool status = false; try { status = CheckData(ref req_lead, ref err); if (status == false) { NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, "CheckData error: " + err); return(respHdr); } InternalLeadReq req = new InternalLeadReq(); req.req = req_lead; status = ImportLead(ref req, ref err); respHdr._postArgs = req._postArgs; return(respHdr); } catch (Exception exception) { err = exception.ToString(); NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, exception.Message, exception); return(respHdr); } finally { respHdr.Successful = status; respHdr.Error = err; } }
private bool ImportLead(ref InternalLeadReq leadReq, ref string err) { err = string.Empty; int LoanId = 0; PostLeadRequest req = leadReq.req; if (req == null || req.RequestHeader == null) { Utilities.LPLog.LogMessage("ImportLead, PostLeadRequest or RequestHeader is null."); return(false); } if (leadReq._postArgs == null) { leadReq._postArgs = new PostArgs(); } #region check duplicates //gdc 20130303 CR61 if (!string.IsNullOrEmpty(req.LeadId) && req.CheckDuplicate == true) { string sqlCmd = string.Format("Select TOP 1 FileId from Loans where GlobalId='{0}'", req.LeadId); object obj = focusIT.DbHelperSQL.GetSingle(sqlCmd); LoanId = (obj == null || obj == DBNull.Value) ? 0 : (int)obj; } //gdc 20130303 CR61 end #endregion if (!string.IsNullOrEmpty(req.BranchName) || (!string.IsNullOrEmpty(req.LoanOfficerFirstName) && !string.IsNullOrEmpty(req.LoanOfficerLastName))) { Find_Setup_Branch_LO(req.BranchName, req.LoanOfficerFirstName, req.LoanOfficerLastName, ref leadReq._postArgs); } int BorrowerId = 0; DataAccess.DataAccess da = new DataAccess.DataAccess(); if (LoanId > 0) //CR61 { try { BorrowerId = da.GetBorrowerContactID(LoanId); } catch (Exception e) { Utilities.LPLog.LogMessage("ImportLead, Exception: " + e.ToString()); } } BorrowerId = CreateContact(req, leadReq._postArgs.LoanOfficerId, BorrowerId, true, ref err); if (BorrowerId <= 0) { Utilities.LPLog.LogMessage("ImportLead, failed to create Borrower Contact records, Error:" + err); return(false); } // save the loan record LoanId = CreateLoan(req, BorrowerId, leadReq._postArgs.BranchId, leadReq._postArgs.LoanOfficerId, ref err); if (LoanId <= 0) { Utilities.LPLog.LogMessage("ImportLead, failed to create Loan records, Error:" + err); return(false); } leadReq._postArgs.ContactId = BorrowerId; leadReq._postArgs.LoanId = LoanId; SendEmailLeadCreated(LoanId); if (string.IsNullOrEmpty(req.CoBorrowerFirstName) || string.IsNullOrEmpty(req.CoBorrowerLastName)) { return(true); } int CoBorrowerId = 0; CoBorrowerId = CreateContact(req, leadReq._postArgs.LoanOfficerId, CoBorrowerId, false, ref err); if (CoBorrowerId <= 0) { Utilities.LPLog.LogMessage("ImportLead, failed to create Coborrower Contact records, Error:" + err); return(false); } return(true); }