mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
finished CRUD on pages
This commit is contained in:
@@ -5,6 +5,7 @@ using CanvasModel.Courses;
|
||||
using CanvasModel.EnrollmentTerms;
|
||||
using CanvasModel.Modules;
|
||||
using RestSharp;
|
||||
using CanvasModel.Pages;
|
||||
|
||||
namespace Management.Services.Canvas;
|
||||
|
||||
@@ -145,6 +146,31 @@ public class CanvasService(
|
||||
var request = new RestRequest(url);
|
||||
request.AddBody(body);
|
||||
|
||||
var (newItem, _response) = await webRequestor.PostAsync<CanvasModuleItem>(request);
|
||||
if (newItem == null)
|
||||
throw new Exception("something went wrong updating module item with string content id");
|
||||
}
|
||||
public async Task CreatePageModuleItem(
|
||||
ulong canvasCourseId,
|
||||
ulong canvasModuleId,
|
||||
string title,
|
||||
CanvasPage canvasPage
|
||||
)
|
||||
{
|
||||
logger.Log($"creating new module item {title}");
|
||||
var url = $"courses/{canvasCourseId}/modules/{canvasModuleId}/items";
|
||||
var body = new
|
||||
{
|
||||
module_item = new
|
||||
{
|
||||
title,
|
||||
type = "Page",
|
||||
page_url = canvasPage.Url,
|
||||
}
|
||||
};
|
||||
var request = new RestRequest(url);
|
||||
request.AddBody(body);
|
||||
|
||||
var (newItem, _response) = await webRequestor.PostAsync<CanvasModuleItem>(request);
|
||||
if (newItem == null)
|
||||
throw new Exception("something went wrong updating module item with string content id");
|
||||
|
||||
Reference in New Issue
Block a user