//
        //GET: /Schools/{Id of a school}/Classes/6510F0FC-53B3-4D9B-9742-84C9C8FA2BE4/UserId
        public async Task <ActionResult> AddCoTeacher(string schoolId, string sectionId, string userId)
        {
            var graphServiceClient = await AuthenticationHelper.GetGraphServiceClientAsync();

            var directoryObj = new Microsoft.Graph.DirectoryObject {
                Id = userId
            };

            try{
                await graphServiceClient.Groups[sectionId].Members.References.Request().AddAsync(directoryObj);
                await graphServiceClient.Groups[sectionId].Owners.References.Request().AddAsync(directoryObj);
            }
            catch (Microsoft.Graph.ServiceException ex) {
            }
            return(RedirectToAction("ClassDetails", new { schoolId = schoolId, sectionId = sectionId }));
        }
예제 #2
0
 /// <summary>
 /// Adds the specified DirectoryObject to the collection via POST.
 /// </summary>
 /// <param name="directoryObject">The DirectoryObject to add.</param>
 /// <returns>The task to await.</returns>
 public System.Threading.Tasks.Task AddAsync(DirectoryObject directoryObject)
 {
     return(this.AddAsync(directoryObject, CancellationToken.None));
 }
예제 #3
0
 /// <summary>
 /// Updates the specified DirectoryObject using PATCH.
 /// </summary>
 /// <param name="directoryObjectToUpdate">The DirectoryObject to update.</param>
 /// <returns>The updated DirectoryObject.</returns>
 public System.Threading.Tasks.Task <DirectoryObject> UpdateAsync(DirectoryObject directoryObjectToUpdate)
 {
     return(this.UpdateAsync(directoryObjectToUpdate, CancellationToken.None));
 }
예제 #4
0
 /// <summary>
 /// Adds the specified DirectoryObject to the collection via POST.
 /// </summary>
 /// <param name="directoryObject">The DirectoryObject to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created DirectoryObject.</returns>
 public System.Threading.Tasks.Task <DirectoryObject> AddAsync(DirectoryObject directoryObject, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <DirectoryObject>(directoryObject, cancellationToken));
 }
 /// <summary>
 /// Creates the specified DirectoryObject using POST and returns a <see cref="GraphResponse{DirectoryObject}"/> object.
 /// </summary>
 /// <param name="directoryObjectToCreate">The DirectoryObject to create.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The <see cref="GraphResponse{DirectoryObject}"/> object of the request.</returns>
 public System.Threading.Tasks.Task <GraphResponse <DirectoryObject> > CreateResponseAsync(DirectoryObject directoryObjectToCreate, CancellationToken cancellationToken = default)
 {
     this.ContentType = CoreConstants.MimeTypeNames.Application.Json;
     this.Method      = HttpMethods.POST;
     return(this.SendAsyncWithGraphResponse <DirectoryObject>(directoryObjectToCreate, cancellationToken));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="directoryObjectToInitialize">The <see cref="DirectoryObject"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(DirectoryObject directoryObjectToInitialize)
 {
 }
예제 #7
0
 /// <summary>
 /// Adds the specified DirectoryObject to the collection via POST.
 /// </summary>
 /// <param name="directoryObject">The DirectoryObject to add.</param>
 /// <returns>The task to await.</returns>
 public Task AddAsync(DirectoryObject directoryObject)
 {
     return(this.AddAsync(directoryObject, CancellationToken.None));
 }
 /// <summary>
 /// Creates the specified DirectoryObject using PUT.
 /// </summary>
 /// <param name="directoryObjectToCreate">The DirectoryObject to create.</param>
 /// <returns>The created DirectoryObject.</returns>
 public Task <DirectoryObject> CreateAsync(DirectoryObject directoryObjectToCreate)
 {
     return(this.CreateAsync(directoryObjectToCreate, CancellationToken.None));
 }