public bool UpdateOpportunity(Guid id, ProxyOpportunity opp) { //var xrm = new XrmServiceContext("Xrm"); Xrm.Opportunity orig = this.xrm.OpportunitySet.Where(c => c.Id == id).FirstOrDefault(); orig.Description = opp.Description; xrm.Update(orig); return true; }
public static ProxyOpportunity ConvertToReadableOpportunity(Opportunity orig, XrmServiceContext context) { ProxyOpportunity co = new ProxyOpportunity(); //using (Xrm.XrmServiceContext context = new XrmServiceContext("Xrm")) //{ co.Id = orig.Id; co.OpportunityId = orig.OpportunityId; co.Name = orig.Name; co.Description = orig.Description; co.ProjectDescription = orig.new_ProjectDescription; co.ProjectRationale = orig.new_ProjectRationale; co.Country = EnsureValueFromOptionSet(orig, "new_country"); co.Region = EnsureValueFromOptionSet(orig, "new_region"); co.Sector = EnsureValueFromOptionSet(orig, "new_sector"); co.SubSector = EnsureValueFromOptionSet(orig, "new_subsector"); var selectedCurrency = context.TransactionCurrencySet.Where(x => x.TransactionCurrencyId == orig.TransactionCurrencyId.Id).FirstOrDefault(); co.Currency = selectedCurrency.CurrencyName; //new_ApprovalLevel co.ApprovalLevel = EnsureValueFromOptionSet(orig, "new_approvallevel"); //BudgetAmount co.BudgetAmount = orig.BudgetAmount; // ? orig.BudgetAmount.Value : 0; //new_Guarantee co.Guarantee = orig.new_Guarantee.HasValue ? (orig.new_Guarantee.Value ? "Yes" : "No") : string.Empty; //new_Borrower co.Borrower = orig.new_Borrower; //new_CategoryType co.CategoryType = EnsureValueFromOptionSet(orig, "new_categorytype"); //new_ModeofFinancialAssistance co.ModeOfFinancialAssistance = EnsureValueFromOptionSet(orig, "new_modeoffinancialassistance"); //new_ProcessingCategory co.ProcessingCategory = EnsureValueFromOptionSet(orig, "new_processingcategory"); //new_ProcessingScenario co.processingScenario = EnsureValueFromOptionSet(orig, "new_processingscenario"); //new_ProjectStage co.ProjectStage = EnsureValueFromOptionSet(orig, "new_projectstage"); //new_expectedapprovalyear co.ExpectedApprovalYear = EnsureValueFromOptionSet(orig, "new_expectedapprovalyear"); //new_additionalfinancing co.AdditionalFinancing = orig.new_AdditionalFinancing.HasValue ? (orig.new_AdditionalFinancing.Value ? "Yes" : "No") : string.Empty; //statuscode co.ProjectStatus = EnsureValueFromOptionSet(orig, "statuscode"); co.TaskStatus = EnsureValueFromOptionSet(orig, "new_taskstatus"); co.Department = orig.new_Department; co.ClosingDate = orig.EstimatedCloseDate; co.Division = EnsureValueFromOptionSet(orig, "new_division"); // orig.new_Division; co.DivisionRole = EnsureValueFromOptionSet(orig, "new_divisionrole"); co.NSProjectType = EnsureValueFromOptionSet(orig, "new_nsprojecttype"); co.NSCoreSector = EnsureValueFromOptionSet(orig, "new_nscoresector"); co.NSOProcessingCategory = EnsureValueFromOptionSet(orig, "new_nsoprocessingcategory");//co.NSOProcessingCategory; //EnsureValueFromOptionSet(orig, "new_nsoprocessingcategory"); co.ProjectNo = orig.new_ProjectNumber; //co.Agencies = ConvertToProxyAccount(orig.new_opportunity_account.ToList()).ToArray(); //co.RealOpportunity = orig; //co.teams = orig.opportunity_Teams; //co.c1 = orig.opportunity_connections1; //co.c2 = orig.opportunity_connections2; co.PRFApproval = orig.new_PRFApproval.HasValue ? orig.new_PRFApproval.Value.ToString() : string.Empty; co.CRPICM = orig.new_CRPICM.HasValue ? orig.new_CRPICM.ToString() : string.Empty; co.LetterOfNoObjection = orig.new_LetterofNoObjection.HasValue ? orig.new_LetterofNoObjection.Value.ToString() : string.Empty; co.FinalReviewICM = orig.new_FinalReviewICM.HasValue ? orig.new_FinalReviewICM.Value.ToString() : string.Empty; co.RRPApproval = orig.new_RRPApproval.HasValue ? orig.new_RRPApproval.Value.ToString() : string.Empty; co.SigningDate = orig.new_SigningDate.HasValue ? orig.new_SigningDate.Value.ToString() : string.Empty; co.EffectivenessDate = orig.new_EffectivenessDate.HasValue ? orig.new_EffectivenessDate.Value.ToString() : string.Empty; co.XARRDate = orig.new_XARR.HasValue ? orig.new_XARR.Value.ToString() : string.Empty; co.ProjectEndDate = orig.new_ProjectEndDate.HasValue ? orig.new_ProjectEndDate.Value.ToString() : string.Empty; return co; }
public static ProxyOpportunity ConvertToReadableOpportunity(Opportunity orig, XrmServiceContext context) { ProxyOpportunity co = new ProxyOpportunity(); //using (Xrm.XrmServiceContext context = new XrmServiceContext("Xrm")) //{ co.Id = orig.Id; co.OpportunityId = orig.OpportunityId; co.Name = orig.Name; co.Description = orig.Description; co.ProjectDescription = orig.new_ProjectDescription; co.ProjectRationale = orig.new_ProjectRationale; co.Country = EnsureValueFromOptionSet(orig, "new_country"); co.Region = EnsureValueFromOptionSet(orig, "new_region"); co.Sector = EnsureValueFromOptionSet(orig, "new_sector"); co.SubSector = EnsureValueFromOptionSet(orig, "new_subsector"); var selectedCurrency = context.TransactionCurrencySet.Where(x => x.TransactionCurrencyId == orig.TransactionCurrencyId.Id).FirstOrDefault(); co.Currency = selectedCurrency.CurrencyName; //new_ApprovalLevel co.ApprovalLevel = EnsureValueFromOptionSet(orig, "new_approvallevel"); //BudgetAmount co.BudgetAmount = orig.BudgetAmount; // ? orig.BudgetAmount.Value : 0; //new_Guarantee co.Guarantee = orig.new_Guarantee.HasValue ? (orig.new_Guarantee.Value ? "Yes" : "No") : string.Empty; //new_Borrower co.Borrower = orig.new_Borrower; //new_CategoryType co.CategoryType = EnsureValueFromOptionSet(orig, "new_categorytype"); //new_ModeofFinancialAssistance co.ModeOfFinancialAssistance = EnsureValueFromOptionSet(orig, "new_modeoffinancialassistance"); //new_ProcessingCategory co.ProcessingCategory = EnsureValueFromOptionSet(orig, "new_processingcategory"); //new_ProcessingScenario co.processingScenario = EnsureValueFromOptionSet(orig, "new_processingscenario"); //new_ProjectStage co.ProjectStage = EnsureValueFromOptionSet(orig, "new_projectstage"); //new_expectedapprovalyear co.ExpectedApprovalYear = EnsureValueFromOptionSet(orig, "new_expectedapprovalyear"); //new_additionalfinancing co.AdditionalFinancing = orig.new_AdditionalFinancing.HasValue ? (orig.new_AdditionalFinancing.Value ? "Yes" : "No") : string.Empty; //statuscode co.ProjectStatus = EnsureValueFromOptionSet(orig, "statuscode"); co.TaskStatus = EnsureValueFromOptionSet(orig, "new_taskstatus"); co.Department = orig.new_Department; co.ClosingDate = orig.EstimatedCloseDate; co.Division = EnsureValueFromOptionSet(orig, "new_division"); // orig.new_Division; co.DivisionRole = EnsureValueFromOptionSet(orig, "new_divisionrole"); co.NSProjectType = EnsureValueFromOptionSet(orig, "new_nsprojecttype"); co.NSCoreSector = EnsureValueFromOptionSet(orig, "new_nscoresector"); co.NSOProcessingCategory = EnsureValueFromOptionSet(orig, "new_nsoprocessingcategory"); //co.NSOProcessingCategory; //EnsureValueFromOptionSet(orig, "new_nsoprocessingcategory"); co.ProjectNo = orig.new_ProjectNumber; //co.Agencies = ConvertToProxyAccount(orig.new_opportunity_account.ToList()).ToArray(); //co.RealOpportunity = orig; //co.teams = orig.opportunity_Teams; //co.c1 = orig.opportunity_connections1; //co.c2 = orig.opportunity_connections2; co.PRFApproval = orig.new_PRFApproval.HasValue ? orig.new_PRFApproval.Value.ToString() : string.Empty; co.CRPICM = orig.new_CRPICM.HasValue ? orig.new_CRPICM.ToString() : string.Empty; co.LetterOfNoObjection = orig.new_LetterofNoObjection.HasValue ? orig.new_LetterofNoObjection.Value.ToString() : string.Empty; co.FinalReviewICM = orig.new_FinalReviewICM.HasValue ? orig.new_FinalReviewICM.Value.ToString() : string.Empty; co.RRPApproval = orig.new_RRPApproval.HasValue ? orig.new_RRPApproval.Value.ToString() : string.Empty; co.SigningDate = orig.new_SigningDate.HasValue ? orig.new_SigningDate.Value.ToString() : string.Empty; co.EffectivenessDate = orig.new_EffectivenessDate.HasValue ? orig.new_EffectivenessDate.Value.ToString() : string.Empty; co.XARRDate = orig.new_XARR.HasValue ? orig.new_XARR.Value.ToString() : string.Empty; co.ProjectEndDate = orig.new_ProjectEndDate.HasValue ? orig.new_ProjectEndDate.Value.ToString() : string.Empty; return(co); }