Skip to content

Instantly share code, notes, and snippets.

View ashelopukho's full-sized avatar
🐑

Alexander Shelopukho ashelopukho

🐑
View GitHub Profile
@ashelopukho
ashelopukho / GraphClientExtensions.cs
Created March 2, 2023 11:16
Asp.net WebApi + GraphServiceClient v5
public static class GraphClientExtensions
{
public static IServiceCollection AddMicrosoftGraphClient(this IServiceCollection services)
{
services.AddScoped(sp =>
{
var tokenAcquisition = sp.GetRequiredService<ITokenAcquisition>();
var authenticationProvider = new BaseBearerTokenAuthenticationProvider(new TokenProvider(tokenAcquisition));
var graphServiceClient = new GraphServiceClient(authenticationProvider);
return graphServiceClient;
@ashelopukho
ashelopukho / icsGen
Created January 18, 2019 16:37
icsGen
using Ical.Net;
using Ical.Net.CalendarComponents;
using Ical.Net.DataTypes;
using Ical.Net.Serialization;
using Microsoft.SharePoint;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
@ashelopukho
ashelopukho / pnp-update-multiple-items.js
Last active November 19, 2018 09:24
Update multiple items: pnp js
(async () => {
const batch = pnp.sp.web.createBatch();
const list = pnp.sp.web.lists.getByTitle('ListA');
const items = await list.items.select('Id,Title').get();
const entityTypeFullName = await list.getListItemEntityTypeFullName();
for (const item of items) {
list.items.getById(item.Id).inBatch(batch)
.update({ Title: `${item.Title} (${item.Id})` }, '*', entityTypeFullName);
}