public void GeneralLoadTestDynamicsCRM() { CrmConnection crmConnection = (CrmConnection)connection.GetConnection(); IOrganizationService service = new OrganizationService(crmConnection); Guid account1 = CreateAccount1(service); string contactName1 = Guid.NewGuid().ToString(); Guid contact1 = CreateContact1(service, contactName1, account1); LoadFromDynamicsCrmConfiguration configuration = new LoadFromDynamicsCrmConfiguration(); configuration.QueryType = DynamicsCrmQueryType.ExecuteFetchXml; configuration.FetchXml = GetTestFetchXml(contactName1); IDataSource loadFromDynamicsCrm = new LoadFromDynamicsCrm() { Configuration = configuration }; IDatastore dataObject = DataStoreFactory.GetDatastore(); loadFromDynamicsCrm.LoadData(connection, dataObject, ReportProgressMethod); var firstObject = dataObject[0]; Assert.AreEqual <string>(contactName1, firstObject[dataObject.Metadata["firstname"].ColumnIndex].ToString()); service.Delete("contact", contact1); service.Delete("account", account1); ((OrganizationService)service).Dispose(); }
public void Can_create_and_delete_organization() { // This is crappy testing because a failed test requires a manual database clean, it's a sample! var service = new OrganizationService(); const string orgName = "Joe's Fish Shack"; var id = GetOrgIdCreatingIfNeeded(service, orgName); Assert.AreNotEqual(0, id); var orgResult = service.Get(id); Assert.IsTrue(orgResult.IsSuccessful); var org = orgResult.Data; Assert.IsNotNull(org); Assert.AreEqual(orgName, org.Name); var deleteResult = service.Delete(org); Assert.IsTrue(orgResult.IsSuccessful); orgResult = service.Get(id); Assert.IsTrue(orgResult.IsSuccessful); org = orgResult.Data; Assert.IsNull(org); }
public ActionResult Delete(int id, FormCollection collection) { try { OrganizationService os = new OrganizationService(); organization o = os.GetById(id); OrganizationViewModel om = new OrganizationViewModel(); om.id = o.id; om.name = o.name; om.type = o.type; om.President = us.GetById((int)o.PresidentID); user i = om.President; o.PresidentID = null; i.DTYPE = "user"; us.Update(i); us.Commit(); os.Delete(o); os.Commit(); return(RedirectToAction("Index")); } catch { return(View()); } }
public OrganizationsControllerTests() { var list = new List <Organization> { new Organization { Id = 1, Name = "test 1" }, new Organization { Id = 2, Name = "test 2" } }.AsQueryable(); var mockContext = Substitute.For <TtContext>(); var organizationRepository = Substitute.For <Repository <Organization> >(mockContext); _service = Substitute.For <OrganizationService>(organizationRepository); _service.GetList().Returns(list); _service.GetItem(Arg.Any <int>()).Returns(new Organization { Id = 1, Name = "test 1" }); _service.Create(Arg.Any <Organization>()); _service.Update(Arg.Any <int>(), Arg.Any <Organization>()); _service.Delete(Arg.Any <int>()); var mockLogger = Substitute.For <ILoggerFactory>(); _controller = new OrganizationsController(_service, mockLogger); }
public void Test_CaseImport() { CrmConnection crmConnection = (CrmConnection)connection.GetConnection(); IOrganizationService service = new OrganizationService(crmConnection); string accountName1 = Guid.NewGuid().ToString(); Entity account = new Entity("account"); account.Attributes.Add("name", accountName1); Guid account1 = service.Create(account); IntegrationTool.Module.WriteToDynamicsCrm.WriteToDynamicsCrmConfiguration writeToCrmConfig = new IntegrationTool.Module.WriteToDynamicsCrm.WriteToDynamicsCrmConfiguration(); writeToCrmConfig.EntityName = "incident"; writeToCrmConfig.PrimaryKeyAttributes.Add("ticketnumber"); writeToCrmConfig.ImportMode = Module.WriteToDynamicsCrm.SDK.Enums.ImportMode.All; writeToCrmConfig.MultipleFoundMode = Module.WriteToDynamicsCrm.SDK.Enums.MultipleFoundMode.All; writeToCrmConfig.Mapping.Add(new IntegrationTool.DataMappingControl.DataMapping() { Source = "CaseID", Target = "ticketnumber" }); writeToCrmConfig.Mapping.Add(new IntegrationTool.DataMappingControl.DataMapping() { Source = "CaseTitle", Target = "title" }); writeToCrmConfig.RelationMapping.Add(new Module.WriteToDynamicsCrm.SDK.RelationMapping() { EntityName = "account", LogicalName = "customerid", Mapping = new List <DataMappingControl.DataMapping>() { new DataMappingControl.DataMapping() { Source = "CompanyName", Target = "name" } } }); writeToCrmConfig.ConfigurationId = Guid.NewGuid(); writeToCrmConfig.SelectedConnectionConfigurationId = Test_Helpers.CRMCONNECTIONID; IDatastore dataObject = DataStoreFactory.GetDatastore(); dataObject.AddColumn(new ColumnMetadata("CaseID")); dataObject.AddColumn(new ColumnMetadata("CaseTitle")); dataObject.AddColumn(new ColumnMetadata("CompanyName")); dataObject.AddData(new object[] { "CA-100", "101 Title", accountName1 }); dataObject.AddData(new object[] { "CA-101", "Anöther Title", null }); dataObject.AddData(new object[] { "CA-102", "A'Title\"chen", accountName1 }); IModule module = Activator.CreateInstance(typeof(WriteToDynamicsCrm)) as IModule; module.SetConfiguration(writeToCrmConfig); ((IDataTarget)module).WriteData(connection, new DummyDatabaseInterface(), dataObject, Test_Helpers.ReportProgressMethod); service.Delete("account", account1); }
public override int DeleteProfiles(ProfileInfoCollection profiles) {//JH using (OrganizationService service = new OrganizationService(OurConnect())) { int deletedProfiles = 0; foreach (ProfileInfo p in profiles) { ConditionExpression usernameCondition = new ConditionExpression(); usernameCondition.AttributeName = consts.username; usernameCondition.Operator = ConditionOperator.Equal; usernameCondition.Values.Add(p.UserName); FilterExpression filter = new FilterExpression(); filter.Conditions.Add(usernameCondition); QueryExpression query = new QueryExpression(consts.userprofile); query.ColumnSet.AddColumn(consts.username); query.Criteria.AddFilter(filter); EntityCollection collection = service.RetrieveMultiple(query); service.Delete(consts.username, collection.Entities[0].Id); deletedProfiles++; } return(deletedProfiles); } }
/// <summary> /// Deletes any entity records that were created for this sample. /// <param name="prompt">Indicates whether to prompt the user /// to delete the records created in this sample.</param> /// </summary> public void DeleteRequiredRecords(bool prompt) { bool deleteRecords = true; if (prompt) { Println(""); DialogResult dialogResult = MessageBox.Show("Do you want the created entity records deleted?", "Delete Records", MessageBoxButtons.YesNoCancel); if (dialogResult == DialogResult.Yes || dialogResult == DialogResult.Cancel) { deleteRecords = true; } else { deleteRecords = false; } } if (deleteRecords) { _orgService.Delete(Account.EntityLogicalName, _accountId); Println("Entity records have been deleted."); } }
protected override void ProcessRecord() { base.ProcessRecord(); base.WriteVerbose(string.Format("Deleting Entity: {0} {1}", EntityName, Id)); OrganizationService.Delete(EntityName, Id); base.WriteVerbose(string.Format("Entity Deleted: {0} {1}", EntityName, Id)); }
public async Task DeleteTest() { var fakeRepository = Mock.Of <IOrganizationRepository>(); var organizationService = new OrganizationService(fakeRepository); var organization = new Organization() { Name = "Dias", Address = " IITU Zhandosov st." }; await organizationService.Delete(organization); }
// GET: Organization/Delete/5 public ActionResult Delete(int id) { try { var service = new OrganizationService(); service.Delete(id); return(RedirectToAction("Index")); } catch (Exception e) { return(View(e.Message)); } }
protected override void ProcessRecord() { base.ProcessRecord(); base.WriteVerbose(string.Format("Deleting Entity: {0} {1}", EntityName, Id)); CrmConnection connection = CrmConnection.Parse(connectionString); using (OrganizationService service = new OrganizationService(connection)) { service.Delete(EntityName, Id); base.WriteVerbose(string.Format("Entity Deleted: {0} {1}", EntityName, Id)); } }
public void DeleteValue(string name) { Logger.LogVerbose("Deleting EnvironmentVariableValue for EnvironmentVariableDefinition with SchemeName {0}", name); EnvironmentVariableValue current = GetValueRecord(name); if (current != null) { Logger.LogVerbose("Deleting EnvironmentVariableValue with Id = {0}", current.Id); OrganizationService.Delete(current.LogicalName, current.Id); Logger.LogInformation("Deleted EnvironmentVariableValue with Id = {0}", current.Id); } else { Logger.LogInformation("Skipping Delete as no EnvironmentVariableValue found for EnvironmentVariableDefinition with SchemeName {0}", name); } }
public void DeleteSolution(string uniqueName) { Solution solution = GetSolution(uniqueName, new ColumnSet()); if (solution == null) { Logger.LogWarning("Solution '{0}' was not found", uniqueName); } else { Logger.LogVerbose("Deleting solution '{0}'", uniqueName); OrganizationService.Delete(Solution.EntityLogicalName, solution.Id); Logger.LogInformation("Solution '{0}' was deleted", uniqueName); } }
/// <summary> /// Deletes any entity records that were created for this sample. /// <param name="prompt">Indicates whether to prompt the user /// to delete the records created in this sample.</param> /// </summary> public void DeleteRequiredRecords(bool prompt) { bool deleteRecords = true; if (prompt) { Console.Write("\nDo you want these entity records deleted? (y/n) [y]: "); String answer = Console.ReadLine(); deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y") || answer == String.Empty); } if (deleteRecords) { _orgService.Delete(Account.EntityLogicalName, _accountId); Console.WriteLine("Entity records have been deleted."); } }
public ActionResult <Boolean> Delete(int id) { try { string nameIdentifier = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; if (nameIdentifier != null) { return(Ok(_OrganizationService.Delete(id, nameIdentifier))); } else { throw new UnauthorizedAccessException("Unauthorized"); } } catch (Exception e) { return(BadRequest(e.Message)); } }
public override JsonResult DeleteTree() { string id = Request["id"]; OrganizationService service = new OrganizationService(); Guid g = Guid.Empty; if (Guid.TryParse(id, out g)) { //系统组织 service.Delete(id); } else { //统一认证组织 service.DeleteByUarcId(id); } return(Json(new TreeAjaxResult { Result = Result.Success, Message = "操作成功", CurrentNodeId = id }, JsonRequestBehavior.AllowGet)); }
public async void Delete() { var mock = new ServiceMockFacade <IOrganizationRepository>(); var model = new ApiOrganizationRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new OrganizationService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.OrganizationModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLOrganizationMapperMock, mock.DALMapperMockFactory.DALOrganizationMapperMock, mock.BOLMapperMockFactory.BOLTeamMapperMock, mock.DALMapperMockFactory.DALTeamMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.OrganizationModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); }
public async void Delete_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <IOrganizationService, IOrganizationRepository>(); var model = new ApiOrganizationServerRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new OrganizationService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.OrganizationModelValidatorMock.Object, mock.DALMapperMockFactory.DALOrganizationMapperMock, mock.DALMapperMockFactory.DALTeamMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.OrganizationModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <OrganizationDeletedNotification>(), It.IsAny <CancellationToken>())); }
/// <summary> /// Deletes all records modified by me. /// </summary> public void DeleteAllModifiedByPeter(string entityName) { var guid = GetUserGuid("Peter Forro"); var records = _context.AccountSet .Where(a => a.CreatedBy.Id.Equals(guid)) .ToList <Account>(); var counter = 0; foreach (var record in records) { _sw.Start(); _orgService.Delete(entityName, record.Id); _sw.Stop(); var time = _sw.ElapsedMilliseconds; _sw.Reset(); Console.WriteLine( $"{++counter}.: " + $"{record} - " + $"{time}"); } }
public void TestAutoNumber() { CrmConnection c = new CrmConnection("CRM"); var service = new OrganizationService(c); Entity seq = new Entity("ctccrm_autonumbersequence"); var seqName = Guid.NewGuid().ToString(); seq["ctccrm_name"] = seqName; seq["ctccrm_currentvalue"] = 0; var seqID = service.Create(seq); int nextValue = 0; while (nextValue < 10) { AutoNumberManager anm = new AutoNumberManager(); nextValue = anm.GetNextSequence(service, seqName); } service.Delete("ctccrm_autonumbersequence", seqID); }
protected override void ProcessRecord() { base.ProcessRecord(); base.WriteVerbose(string.Format("Removing Solution: {0}", SolutionName)); QueryExpression queryImportedSolution = new QueryExpression { EntityName = Solution.EntityLogicalName, ColumnSet = new ColumnSet(new string[] { "solutionid", "friendlyname" }), Criteria = new FilterExpression() }; queryImportedSolution.Criteria.AddCondition("uniquename", ConditionOperator.Equal, SolutionName); Solution ImportedSolution = (Solution)OrganizationService.RetrieveMultiple(queryImportedSolution).Entities[0]; OrganizationService.Delete(Solution.EntityLogicalName, (Guid)ImportedSolution.SolutionId); base.WriteVerbose(string.Format("Solution {0} Deleted", SolutionName)); }
public async void Delete_ErrorsOccurred_ShouldReturnErrorResponse() { var mock = new ServiceMockFacade <IOrganizationService, IOrganizationRepository>(); var model = new ApiOrganizationServerRequestModel(); var validatorMock = new Mock <IApiOrganizationServerRequestModelValidator>(); validatorMock.Setup(x => x.ValidateDeleteAsync(It.IsAny <int>())).Returns(Task.FromResult(new FluentValidation.Results.ValidationResult(new List <ValidationFailure>() { new ValidationFailure("text", "test") }))); var service = new OrganizationService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, validatorMock.Object, mock.DALMapperMockFactory.DALOrganizationMapperMock, mock.DALMapperMockFactory.DALTeamMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeFalse(); validatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <OrganizationDeletedNotification>(), It.IsAny <CancellationToken>()), Times.Never()); }
// DELETE api/Organizations/5 public void Delete(int id) { OrganizationService.Delete(id); }
public virtual ImportResultModel LanguageConfigImport(string importLogId, string content) { ImportResultModel result = new ImportResultModel(); if (string.IsNullOrWhiteSpace(content)) { return(result); } //解析数据结构,结构为:行、列、值 ImportContentModel contentModel = JsonHelper.Deserialize <ImportContentModel>(content); result.Messages = new List <ImportMessage>(); int i = 1; foreach (Dictionary <string, string> item in contentModel.Rows) { #region 数据有效性验证(包含必填项检查) test string name = string.Empty; Guid languageId = Guid.Empty, outerappId = Guid.Empty, languageConfigId = Guid.Empty; List <int> langId = new List <int>(); bool isError = false; int count = item.Count - 3; int length = 0; foreach (string key in item.Keys) { try { string value = item[key].ToString(); Dictionary <string, string> data = new Dictionary <string, string>(); if (key == "信息代码") { if (string.IsNullOrWhiteSpace(value)) { throw new InvalidPluginExecutionException($"第{ i }行导入失败,原因是:信息代码{ value }为空"); } } if (key != "信息代码" && key != "信息描述" && key != "互联应用") { if (!IsNumeric(key)) { throw new InvalidPluginExecutionException("语言ID有误!"); } //if (!string.IsNullOrWhiteSpace(value)) langId.Add(Convert.ToInt32(key)); } } catch (InvalidPluginExecutionException ex) { ImportMessage import = new ImportMessage() { Message = ex.Message, MessageType = 4 }; result.Messages.Add(import); isError = true; } } #endregion #region 数据存在异常,则跳过,不导入 i++; if (isError) { result.ErrorRecord++; continue; } #endregion #region 创建或更新语言配置 try { Entity languageConfig = new Entity("new_languageconfig"); for (int j = 0; j < count; j++) { // 语言和互联应用的存在性并查询其id QueryExpression queryLanguage = new QueryExpression("new_language"); queryLanguage.ColumnSet.AddColumn("new_languageid"); queryLanguage.Criteria.AddCondition("new_langid", ConditionOperator.Equal, langId[j]); EntityCollection languageList = OrganizationService.RetrieveMultiple(queryLanguage); if (languageList?.Entities?.Count <= 0) { throw new InvalidPluginExecutionException($"语言{ langId[j] }不存在!"); } languageId = languageList.Entities[0].GetAttributeValue <Guid>("new_languageid"); // 互联应用为空:更新为null,有值:查找 if (!string.IsNullOrWhiteSpace(item["互联应用"])) { QueryExpression queryOuterApp = new QueryExpression("new_outerapp"); queryOuterApp.ColumnSet.AddColumn("new_outerappid"); queryOuterApp.Criteria.AddCondition("new_name", ConditionOperator.Equal, item["互联应用"]); EntityCollection outerAppList = OrganizationService.RetrieveMultiple(queryOuterApp); if (outerAppList?.Entities?.Count <= 0) { throw new InvalidPluginExecutionException("互联应用不存在!"); } outerappId = outerAppList.Entities[0].GetAttributeValue <Guid>("new_outerappid"); languageConfig["new_outerapp_id"] = new EntityReference("new_outerapp", outerappId); } else { languageConfig["new_outerapp_id"] = null; } // 创建、更新及删除 languageConfig["new_name"] = item["信息代码"]; languageConfig["new_language_id"] = new EntityReference("new_language", languageId); languageConfig["new_content"] = item[langId[j].ToString()]; languageConfig["new_note"] = item["信息描述"]; // 获取语言配置 QueryExpression queryLanguageConfig = new QueryExpression("new_languageconfig"); queryLanguageConfig.ColumnSet.AddColumn("new_languageconfigid"); queryLanguageConfig.Criteria.AddCondition("new_name", ConditionOperator.Equal, item["信息代码"]); queryLanguageConfig.Criteria.AddCondition("new_language_id", ConditionOperator.Equal, languageId); EntityCollection languageConfigList = OrganizationService.RetrieveMultiple(queryLanguageConfig); if (languageConfigList?.Entities?.Count <= 0) { if (string.IsNullOrWhiteSpace(item[langId[j].ToString()])) { continue; } OrganizationService.Create(languageConfig); } else { if (string.IsNullOrWhiteSpace(item[langId[j].ToString()])) { OrganizationService.Delete("new_languageconfig", languageConfigList.Entities[0].GetAttributeValue <Guid>("new_languageconfigid")); continue; } languageConfig.Id = languageConfigList.Entities[0].GetAttributeValue <Guid>("new_languageconfigid"); OrganizationService.Update(languageConfig); } } } catch (InvalidPluginExecutionException ex) { ImportMessage import = new ImportMessage() { Message = ex.Message, MessageType = 4 }; result.Messages.Add(import); isError = true; } #endregion } return(result); }
public ActionResult Delete(int ID) { orgs.Delete(ID); return(RedirectToAction("GetAll")); }
public void Test_ContactImport() { CrmConnection crmConnection = (CrmConnection)connection.GetConnection(); IOrganizationService service = new OrganizationService(crmConnection); string accountName1 = Guid.NewGuid().ToString(); Entity account = new Entity("account"); account.Attributes.Add("name", accountName1); Guid account1 = service.Create(account); IntegrationTool.Module.WriteToDynamicsCrm.WriteToDynamicsCrmConfiguration writeToCrmConfig = new IntegrationTool.Module.WriteToDynamicsCrm.WriteToDynamicsCrmConfiguration(); writeToCrmConfig.EntityName = "contact"; writeToCrmConfig.PrimaryKeyAttributes.Add("new_id"); writeToCrmConfig.ImportMode = Module.WriteToDynamicsCrm.SDK.Enums.ImportMode.All; writeToCrmConfig.MultipleFoundMode = Module.WriteToDynamicsCrm.SDK.Enums.MultipleFoundMode.All; writeToCrmConfig.Mapping.Add(new IntegrationTool.DataMappingControl.DataMapping() { Source = "ID", Target = "new_id" }); writeToCrmConfig.Mapping.Add(new IntegrationTool.DataMappingControl.DataMapping() { Source = "FirstName", Target = "firstname" }); writeToCrmConfig.Mapping.Add(new IntegrationTool.DataMappingControl.DataMapping() { Source = "LastName", Target = "lastname" }); writeToCrmConfig.Mapping.Add(new IntegrationTool.DataMappingControl.DataMapping() { Source = "Status", Target = "statuscode" }); writeToCrmConfig.Mapping.Add(new IntegrationTool.DataMappingControl.DataMapping() { Source = "Birthdate", Target = "birthdate" }); writeToCrmConfig.RelationMapping.Add(new Module.WriteToDynamicsCrm.SDK.RelationMapping() { EntityName = "account", LogicalName = "parentcustomerid", Mapping = new List <DataMappingControl.DataMapping>() { new DataMappingControl.DataMapping() { Source = "CompanyName", Target = "name" } } }); writeToCrmConfig.ConfigurationId = Guid.NewGuid(); writeToCrmConfig.SelectedConnectionConfigurationId = Test_Helpers.CRMCONNECTIONID; writeToCrmConfig.PicklistMapping.Add(new Module.WriteToDynamicsCrm.SDK.PicklistMapping() { LogicalName = "statuscode", MappingType = Module.WriteToDynamicsCrm.SDK.Enums.PicklistMappingType.Manual, Mapping = new List <DataMappingControl.DataMapping>() { new DataMappingControl.DataMapping() { Source = "Active", Target = "1" }, new DataMappingControl.DataMapping() { Source = "Inactive", Target = "2" } } }); IDatastore dataObject = DataStoreFactory.GetDatastore(); dataObject.AddColumn(new ColumnMetadata("FirstName")); dataObject.AddColumn(new ColumnMetadata("LastName")); dataObject.AddColumn(new ColumnMetadata("City")); dataObject.AddColumn(new ColumnMetadata("ID")); dataObject.AddColumn(new ColumnMetadata("CompanyName")); dataObject.AddColumn(new ColumnMetadata("Status")); dataObject.AddColumn(new ColumnMetadata("Birthdate")); dataObject.AddData(new object[] { "Peter", "Widmer", "Wettingen", 1001, accountName1, "Active", new DateTime(1980, 06, 23) }); dataObject.AddData(new object[] { "Joachim 2", "Suter", "Dättwil", 1002, accountName1, "Inactive", new DateTime(2004, 12, 03) }); dataObject.AddData(new object[] { "James", "Brown", "London", 1003, null, "Active", null }); // Doublekey to test it works too dataObject.AddData(new object[] { "Peter", "Widmer", "Wettingen", 1001, accountName1, "Active", new DateTime(1980, 06, 23) }); IModule module = Activator.CreateInstance(typeof(WriteToDynamicsCrm)) as IModule; module.SetConfiguration(writeToCrmConfig); ((IDataTarget)module).WriteData(connection, new DummyDatabaseInterface(), dataObject, Test_Helpers.ReportProgressMethod); service.Delete("account", account1); }
public IActionResult Delete(Guid id) { return(Ok(_organizationService.Delete(id))); }
//receives a username string and a "delete all related data" boolean //returns false if the user does not exist //returns true if user data was deleted(soft delete, hard delete optional) public override bool DeleteUser(string username, bool deleteAllRelatedData) { //tc using (OrganizationService service = new OrganizationService(OurConnect())) { ConditionExpression usernameCondition = new ConditionExpression(); ConditionExpression deleteCondition = new ConditionExpression(); ConditionExpression appCondition = new ConditionExpression(); usernameCondition.AttributeName = consts.username; usernameCondition.Operator = ConditionOperator.Equal; usernameCondition.Values.Add(username); deleteCondition.AttributeName = consts.deleteduser; deleteCondition.Operator = ConditionOperator.Equal; deleteCondition.Values.Add(false); appCondition.AttributeName = consts.appname; appCondition.Operator = ConditionOperator.Equal; appCondition.Values.Add(_ApplicationName); FilterExpression filter = new FilterExpression(); filter.Conditions.Add(usernameCondition); filter.Conditions.Add(appCondition); QueryExpression query = new QueryExpression(consts.useraccount); query.ColumnSet.AddColumn(consts.username); query.ColumnSet.AddColumn(consts.deleteduser); query.Criteria.AddFilter(filter); EntityCollection collection = service.RetrieveMultiple(query); if (collection.Entities.Count == 0) { return false; } else { if (!deleteAllRelatedData) { collection.Entities[0][consts.deleteduser] = true; activity(username, "Deleted", true); service.Update(collection.Entities[0]); return true; } else {//hard delete service.Delete(consts.useraccount, collection.Entities[0].Id); return true; } } } }
public static void DeleteRecord(Guid id, OrganizationService service) { service.Delete("icl_case", id); }
public void Delete(string entityName, Guid id) { _orgService.Delete(entityName, id); }
public void DeleteWebResource(WebResource webResource) { orgService.Delete(webResource.LogicalName, webResource.Id); }
public override int DeleteProfiles(string[] usernames) { //JH using (OrganizationService service = new OrganizationService(OurConnect())) { int deletedProfiles = 0; foreach(string user in usernames){ ConditionExpression usernameCondition = new ConditionExpression(); usernameCondition.AttributeName = consts.username; usernameCondition.Operator = ConditionOperator.Equal; usernameCondition.Values.Add(user); FilterExpression filter = new FilterExpression(); filter.Conditions.Add(usernameCondition); QueryExpression query = new QueryExpression(consts.userprofile); query.ColumnSet.AddColumn(consts.username); query.Criteria.AddFilter(filter); EntityCollection collection = service.RetrieveMultiple(query); service.Delete(consts.userprofile, collection.Entities[0].Id); deletedProfiles++; } return deletedProfiles; } }