/// <summary> /// Reassigns the quotes. /// </summary> /// <param name="quoteIdList">The quote identifier list.</param> /// <param name="newOpportunityID">The new opportunity identifier.</param> /// <param name="newCRMOppID">The new CRM opp identifier.</param> /// <returns></returns> public int ReassignQuotes(int clientId, string quoteIdList, int newOpportunityID, string newCRMOppID) { List <int?> opportunityIdList = new List <int?>(); var quoteDl = new QuoteDL(); int result = quoteDl.ReassignQuotes(clientId, quoteIdList, newOpportunityID, newCRMOppID, ref opportunityIdList); var opportunityDl = new OpportunityDL(); foreach (int opportunityID in opportunityIdList) { try { result += opportunityDl.CalculateOpportunityRollups(opportunityID); } catch (Exception e) { _applicationLogDL.AddErrorMessage(0, "Calculate rollup returned error for oppId:" + opportunityID, e.Message); } } try { result += opportunityDl.CalculateOpportunityRollups(newOpportunityID); } catch (Exception e) { _applicationLogDL.AddErrorMessage(0, "Calculate rollup returned error for oppId:" + newOpportunityID, e.Message); } return(result); }
/// <summary> /// Updates the quote rollup. /// </summary> /// <param name="opportunityID">The opportunity identifier.</param> /// <param name="quoteID">The quote identifier.</param> /// <param name="rollup">The rollup.</param> /// <returns></returns> public int UpdateQuoteRollup(int opportunityID, string quoteID, string rollup) { var quoteDl = new QuoteDL(); int result = quoteDl.UpdateQuoteRollup(quoteID, rollup); try { var opportunityDl = new OpportunityDL(); result += opportunityDl.CalculateOpportunityRollups(opportunityID); } catch (Exception e) { _applicationLogDL.AddErrorMessage(0, "Calculate rollup returned error", e.Message); } return(result); }
public Response UpdateSdaCloudOpportunity(List <OpportunityDto> opportunities) { Response response = new Response(); OpportunityDL ydl = new OpportunityDL(); foreach (OpportunityDto dto in opportunities) { string str; try { if (ydl.UpdateOpportunity(dto) > 0) { str = "UPDATE-SDACloud CRM Opportunity Id:" + dto.CRMOppID + ", has been successfully updated"; response.Results.Add(str); this._applicationLogDL.AddTransactionMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto)); continue; } str = "UPDATE-SDACloud CRM Opportunity Id:" + dto.CRMOppID + ", could not be updated"; if (this._applicationLogDL.AddErrorMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto))) { response.Results.Add(str); continue; } response.Errors.Add(str); } catch (Exception exception) { string[] strArray = new string[] { "SDACloud CRM Opportunity Id:", dto.CRMOppID, ",", exception.Message, (exception.InnerException != null) ? exception.InnerException.Message : "" }; str = string.Concat(strArray); if (this._applicationLogDL.AddErrorMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto))) { response.Results.Add(str); continue; } response.Errors.Add(str); } } return(response); }
/// <summary> /// Deletes the quotes. /// </summary> /// <param name="quoteIdList">The quote identifier list.</param> /// <returns></returns> public int DeleteQuotes(string quoteIdList) { List <int?> opportunityIdList = new List <int?>(); var quoteDl = new QuoteDL(); int result = quoteDl.DeleteQuotes(quoteIdList, ref opportunityIdList); var opportunityDl = new OpportunityDL(); foreach (int opportunityID in opportunityIdList) { try { result += opportunityDl.CalculateOpportunityRollups(opportunityID); } catch (Exception e) { _applicationLogDL.AddErrorMessage(0, "Calculate rollup returned error for oppId:" + opportunityID, e.Message); } } return(result); }
/// <summary> /// Gets the statuses. /// </summary> /// <param name="clientId">The client identifier.</param> /// <returns></returns> public List <OppStatusDto> GetStatuses(int clientId) { var opportunityDl = new OpportunityDL(); return(opportunityDl.GetStatuses(clientId)); }
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); }