This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generate the redirect URL for a user to login with a Microsoft account. | |
* - The clientId is the id of the Active Directory application. | |
* - The redirect URL must be configured in that application (https!) | |
* - If an email is given, it will be preselected in the login box. | |
*/ | |
getMsOauthUrl(clientId: string, redirect: string, state: string, email?: string): string | |
{ | |
let url = `https://login.microsoftonline.com/common/oauth2/v2.0/authorize?` + | |
`client_id=${clientId}` + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ApiController] | |
[Route("api/[controller]")] | |
public class BillingController : ControllerBase | |
{ | |
private readonly IBillingApiService service; | |
public BillingController(IBillingApiService service) | |
{ | |
this.service = service; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IBillingApiService | |
{ | |
/// <summary> | |
/// The resolve endpoint enables the publisher to exchange the marketplace purchase identification token | |
/// to a persistent purchased SaaS subscription ID and its details. | |
/// </summary> | |
Task<MicrosoftPurchase> ResolvePurchase(string marketplaceToken); | |
/// <summary> | |
/// Retrieves a list of all purchased SaaS subscriptions for all offers published by the publisher in marketplace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void ReadGardenInfos(GardenContext db, params int[] years) | |
{ | |
var gardenInfos = db.GardenInfos.AsNoTracking() | |
.Include(gi => gi.Garden) | |
.Where(gi => years.Contains(gi.Year)) | |
.OrderBy(gi => gi.Garden.Name).ThenBy(gi => gi.Year) | |
.ToList(); | |
gardenInfos.ForEach(info => Console.WriteLine($"Crops in '{info.Garden.Name}' ({info.Year}): {info.AllGardenCrops}")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
using (var db = new GardenContext()) | |
{ | |
db.Database.Migrate(); | |
CreateViews(db.Database); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GardenContext : DbContext | |
{ | |
public DbSet<Garden> Gardens { get; set; } | |
public DbSet<Bed> Beds { get; set; } | |
public DbSet<Crop> Crops { get; set; } | |
public DbSet<CropAssignment> CropAssignments { get; set; } | |
public DbSet<GardenInfo> GardenInfos { get; set; } | |
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ | |
modelBuilder.Entity<GardenInfo>(d => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select distinct | |
Gardens.GardenId | |
, Gardens.Name | |
, ca.Year | |
,substring( | |
( | |
select ' | '+Crops.Name as [text()] | |
from Crops | |
join CropAssignments on Crops.CropId = CropAssignments.CropId | |
join Beds on Beds.BedId = CropAssignments.BedId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using Microsoft.EntityFrameworkCore; | |
namespace EFCoreBasic | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.ComponentModel.DataAnnotations.Schema; | |
using Microsoft.EntityFrameworkCore; | |
namespace EFCoreBasic | |
{ | |
public class GardenContext : DbContext | |
{ | |
public DbSet<Garden> Gardens { get; set; } | |
public DbSet<Bed> Beds { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.EntityFrameworkCore; | |
namespace TestProject | |
{ | |
public class PersonContext : DbContext | |
{ | |
DbSet<Person> Persons { get; set; } | |
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | |
{ |
NewerOlder