public Response AddSdaCloudOpportunity(List <OpportunityDto> opportunities) { Response response = new Response(); OpportunityDL ydl = new OpportunityDL(); ClientLoginDL ndl = new ClientLoginDL(); foreach (OpportunityDto dto in opportunities) { string str; try { bool manageOpportunitiesInCRM = false; ClientLoginDto dto2 = ndl.ManageOpportunitiesInCRM(dto.ClientID); if (dto2.ManageOppysInCRM) { manageOpportunitiesInCRM = dto2.ManageOppysInCRM; } int oppID = ydl.AddOpportunity(dto, manageOpportunitiesInCRM); if (oppID < 0) { str = "ADD-SDACloud Duplicated record with Quote Id Main Site:" + dto.QuoteIDMainSite + ", could not be added"; if (this._applicationLogDL.AddErrorMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto))) { response.Results.Add(str); } } else if (oppID <= 0) { str = "ADD-SDACloud CRM Opportunity Id:" + dto.CRMOppID + ", could not be added"; if (this._applicationLogDL.AddErrorMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto))) { response.Results.Add(str); } else { response.Errors.Add(str); } } else if (!manageOpportunitiesInCRM && string.IsNullOrEmpty(dto.CRMOppID)) { string[] strArray = new string[] { "ADD-SDACloud CRM Opportunity Id:", ydl.GetNonDeletedOpportunityByClientIDAndOppID(dto.ClientID, oppID).CRMOppID, ":Quote Id Main Site:", dto.QuoteIDMainSite, ", has been successfully added" }; str = string.Concat(strArray); response.Results.Add(str); this._applicationLogDL.AddTransactionMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto)); } else if (!string.IsNullOrEmpty(dto.CRMOppID)) { str = "ADD-SDACloud CRM Opportunity Id:" + dto.CRMOppID + ", has been successfully added"; response.Results.Add(str); this._applicationLogDL.AddTransactionMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto)); } else { str = "ADD-SDACloud Opportunity with Quote Id Main Site:" + dto.QuoteIDMainSite + ", has been successfully added"; response.Results.Add(str); this._applicationLogDL.AddTransactionMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto)); } } catch (Exception exception) { string[] strArray2 = new string[] { "SDACloud CRM Opportunity Id:", dto.CRMOppID, ":Quote Id Main Site:", dto.QuoteIDMainSite, ",", exception.Message, (exception.InnerException != null) ? exception.InnerException.Message : "" }; str = string.Concat(strArray2); if (this._applicationLogDL.AddErrorMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto))) { response.Results.Add(str); continue; } response.Errors.Add(str); } } return(response); }
/// <summary> /// Manages the opportunities in CRM. /// </summary> /// <param name="clientID">The client identifier.</param> /// <returns></returns> public ClientLoginDto ManageOpportunitiesInCRM(int clientID) { var clientLoginDl = new ClientLoginDL(); return(clientLoginDl.ManageOpportunitiesInCRM(clientID)); }