/// <summary> /// To update prospect detail /// </summary> /// <param name="prospectList"></param> /// <param name="userID"></param> /// <param name="shell"></param> /// <param name="role"></param> /// <returns></returns> public Int64 UpdateProspectWithContact(EProspect prospect, string userID, string shell, string role) { FranchisorDAL franchisorDAL = new FranchisorDAL(); Int64 returnresult = franchisorDAL.SaveProspect(prospect, Convert.ToInt32(EOperationMode.Update), userID, shell, role); Int64 returnContactID = 0; int prospectid = 0; if (returnresult == 0) { prospectid = Convert.ToInt32(prospect.ProspectID); if (prospect.AddressMailing != null) { // Save prospect mailing address franchisorDAL.SaveProspectAddress(prospect.AddressMailing, prospectid); } // Save prospect details if (prospect.ProspectDetails != null) { franchisorDAL.SaveProspectDetails(prospect.ProspectDetails, prospectid); } if (prospect.Contact != null && prospect.Contact.Count > 0) { for (int i = 0; i < prospect.Contact.Count; i++) { if (prospect.Contact[i].IsDeleted == false) { // Save Prospect Communication //returnContactID = franchisorDAL.SaveNewProspectContact(prospect.Contact[i], 2, prospectid, Convert.ToInt32(userID)); if (prospect.Contact[i].ContactID > 0) { returnContactID = franchisorDAL.SaveContact(prospect.Contact[i], Convert.ToInt32(EOperationMode.Update), Convert.ToInt32(userID)); if (returnContactID >= 0) { returnContactID = prospect.Contact[i].ContactID; } else { returnContactID = -1; } } else { returnContactID = franchisorDAL.SaveContact(prospect.Contact[i], Convert.ToInt32(EOperationMode.Insert), Convert.ToInt32(userID)); } if (returnContactID > 0) { franchisorDAL.SaveProspectContact(returnContactID, prospectid, true); franchisorDAL.SaveProspectContactRoleMapping(prospect.Contact[i].ListProspectContactRole, returnContactID, prospectid); } } else { //Deactivates the same record franchisorDAL.SaveProspectContact(prospect.Contact[i].ContactID, prospectid, false); } } } } if (prospect.ContactCall != null) { prospect.ContactCall.Contact = new EContact(); prospect.ContactCall.Contact.ContactID = Convert.ToInt32(returnContactID); prospect.ContactCall.ProspectID = prospectid; franchisorDAL.SaveCall(prospect.ContactCall, Convert.ToInt32(EOperationMode.Insert)); } if (prospect.ContactMeeting != null) { prospect.ContactMeeting.Contact = new EContact(); prospect.ContactMeeting.Contact.ContactID = Convert.ToInt32(returnContactID); prospect.ContactMeeting.ProspectID = prospectid; franchisorDAL.SaveMeeting(prospect.ContactMeeting, Convert.ToInt32(EOperationMode.Insert)); } if (prospect.Task != null) { prospect.Task.ContactID = Convert.ToInt32(returnContactID); prospect.Task.ProspectID = prospectid; franchisorDAL.SaveTask(prospect.Task, Convert.ToInt32(EOperationMode.Insert), userID, shell, role); } return(returnresult); }
public Int64 UpdateHostWithContacts(EProspect prospect, string userID, string shell, string role) { FranchisorDAL franchisorDAL = new FranchisorDAL(); Int64 returnresult = franchisorDAL.SaveHost(prospect, Convert.ToInt32(EOperationMode.Update), userID, shell, role); Int64 ContctID = 0; Int64 returnContactID = 0; int prospectid = 0; if (returnresult == 0) { prospectid = Convert.ToInt32(prospect.ProspectID); // Save prospect details if (prospect.ProspectDetails != null) { franchisorDAL.SaveProspectDetails(prospect.ProspectDetails, prospectid); } if (prospect.Contact != null && prospect.Contact.Count > 0) { for (int i = 0; i < prospect.Contact.Count; i++) { if (prospect.Contact[i].IsDeleted == false) { //returnContactID = franchisorDAL.SaveNewProspectContact(prospect.Contact[i], 2, prospectid, Convert.ToInt32(userID)); if (prospect.Contact[i].ContactID > 0) { returnContactID = franchisorDAL.SaveContact(prospect.Contact[i], Convert.ToInt32(EOperationMode.Update), Convert.ToInt32(userID)); if (returnContactID >= 0) { returnContactID = prospect.Contact[i].ContactID; } else { returnContactID = -1; } } else { returnContactID = franchisorDAL.SaveContact(prospect.Contact[i], Convert.ToInt32(EOperationMode.Insert), Convert.ToInt32(userID)); } if (returnContactID > 0) { franchisorDAL.SaveProspectContact(returnContactID, prospectid, true); franchisorDAL.SaveProspectContactRoleMapping(prospect.Contact[i].ListProspectContactRole, returnContactID, prospectid); } } else { //Delete the same record franchisorDAL.SaveProspectContact(prospect.Contact[i].ContactID, prospectid, false); } } } if (ContctID > 0 || prospectid > 0 && (prospect.ContactMeeting != null)) { prospect.ContactMeeting.ProspectID = prospectid; prospect.ContactMeeting.Contact.ContactID = Convert.ToInt32(returnContactID); franchisorDAL.SaveMeeting(prospect.ContactMeeting, Convert.ToInt32(EOperationMode.Insert)); } } return(returnresult); }