static void UpdateProgram(Guid organizationalUnitGuid) { ServiceFactory factory = new ServiceFactory(); IOrganizationalUnitService ouService = factory.CreateOrganizationalUnitService(); var oUnit = new OrganizationalUnit(); // the following are required fields. oUnit.OrganizationalUnitGuid = new Guid(organizationalUnitGuid.ToString()); oUnit.Name = "Updated Organization Unit"; // the following are optional. bool success = ouService.Update(oUnit); if (!success) { Console.WriteLine("ErrorCode: " + ouService.LastError.ErrorCode); Console.WriteLine("ErrorMessage: " + ouService.LastError.ErrorCodeString); } else { Console.WriteLine(string.Format("User {0} was updated.", oUnit.Name)); } }
static Guid CreateProgram() { ServiceFactory factory = new ServiceFactory(); IOrganizationalUnitService ouService = factory.CreateOrganizationalUnitService(); var program = new OrganizationalUnit(); // the following are required fields. program.Name = "A sample program created by API"; program.Abbreviation = "TPCBA"; program.IsProgram = true; // the following are optional fields. Guid guid = ouService.Create(program); bool success = guid != Guid.Empty; if (!success) { Console.WriteLine("ErrorCode: " + ouService.LastError.ErrorCode); Console.WriteLine("ErrorMessage: " + ouService.LastError.ErrorCodeString); return(Guid.Empty); } else { Console.WriteLine(string.Format("Program {0} was created.", program.Name)); return(guid); } }
static void DeleteProgram(Guid organizationalUnitGuid) { ServiceFactory factory = new ServiceFactory(); IOrganizationalUnitService ouService = factory.CreateOrganizationalUnitService(); bool success = ouService.Delete(organizationalUnitGuid); if (!success) { Console.WriteLine("ErrorCode: " + ouService.LastError.ErrorCode); Console.WriteLine("ErrorMessage: " + ouService.LastError.ErrorCodeString); } else { Console.WriteLine(string.Format("Organizational Unit [{0}] was deleted.", organizationalUnitGuid)); } }
static void SearchProgram(string keyword, int offset = 0, int limit = 100) { ServiceFactory factory = new ServiceFactory(); IOrganizationalUnitService ouService = factory.CreateOrganizationalUnitService(); IEnumerable <OrganizationalUnit> organizationalUnitList = ouService.Search(keyword, true, true, offset, limit); if (ouService.LastError != null) { Console.WriteLine("ErrorCode: " + ouService.LastError.ErrorCode); Console.WriteLine("ErrorMessage: " + ouService.LastError.ErrorCodeString); } else { Console.WriteLine(string.Format("Found {0} programs.", organizationalUnitList.Count())); } }
static void GetProgram(Guid organizationalUnitGuid) { ServiceFactory factory = new ServiceFactory(); IOrganizationalUnitService ouService = factory.CreateOrganizationalUnitService(); OrganizationalUnit organizationalUnit = ouService.Get(organizationalUnitGuid); if (ouService.LastError != null) { Console.WriteLine("ErrorCode: " + ouService.LastError.ErrorCode); Console.WriteLine("ErrorMessage: " + ouService.LastError.ErrorCodeString); } else { Console.WriteLine(string.Format("Name of organizational unit is {0}.", organizationalUnit.Name)); } }
public OrganizationsUnitsController(IOrganizationalUnitService orgService, ILogger <UsersController> logger) { _orgService = orgService; _logger = logger; }