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); } }
public IActionResult Post([FromBody] OrganizationalUnitVO orgUnit) { if (orgUnit == null) { return(BadRequest()); } var newOrgUnit = new ObjectResult(_orgService.Create(orgUnit)); if (newOrgUnit.Value == null) { return(Conflict()); } return(newOrgUnit); }