Skip to content

Instantly share code, notes, and snippets.

@laur3d
laur3d / FlowMaker-LowCode.cs
Created Apr 28, 2021
Dynamic Workflows Low Code Style
View FlowMaker-LowCode.cs
namespace dynamicworkflows.Workflows
{
using Jint;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Azure.WebJobs.Extensions.Http;
@laur3d
laur3d / DynamicOrchestrator.cs
Last active Apr 15, 2021
Dynamic Orchestrator
View DynamicOrchestrator.cs
public static class FlowMaker
{
[FunctionName("FlowMaker")]
public static async Task<int> Run([OrchestrationTrigger] IDurableOrchestrationContext context)
{
// imagine this comes from a DB or the request payload
var steps = new DynamicFlowContext
{
Steps = new List<DynamicStep<int>>
View solution2.cs
class Solution
{
static void Main()
{
int L = int.Parse(Console.ReadLine());
int H = int.Parse(Console.ReadLine());
string Sentence = Console.ReadLine().ToUpper();
for (int i = 0; i < H; i++) {
string AsciiRow = Console.ReadLine();
View solution.cs
class Solution
{
static void Main(string[] args)
{
int L = int.Parse(Console.ReadLine());
int H = int.Parse(Console.ReadLine());
var writter = new Writer(H,L);
string T = Console.ReadLine();
View GetCartForSession.cs
[FunctionName("GetCartForSession")]
public static async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "cart/{id}")] HttpRequestMessage req,
Guid id,
[DurableClient] IDurableClient client,
ILogger log)
{
if (id == Guid.Empty)
{
return (ActionResult) new BadRequestObjectResult("The ID is required");
View RemoveItemFromCartActivity.cs
[FunctionName("RemoveItemFromCart")]
public static async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "cart/{id}/remove")] HttpRequestMessage req,
Guid id,
[DurableClient] IDurableClient client, ILogger log)
{
if (id == Guid.Empty)
{
return (ActionResult) new BadRequestObjectResult("Id is required");
View CartItem.cs
public class CartItem
{
public Guid ProductId { get; set; }
public int Count { get; set; }
}
View AddItemToCartTrigger.cs
[FunctionName("AddItemToCart")]
public static async Task<ActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "cart/{id}/add")] HttpRequestMessage req,
Guid id,
[DurableClient] IDurableEntityClient client )
{
if (id == Guid.Empty)
{
return (ActionResult) new BadRequestObjectResult("Id is required");
}
View ShoppingCartEntity.cs
[JsonObject(MemberSerialization.OptIn)]
public class ShoppingCartEntity : IShoppingCart
{
[JsonProperty("list")]
private List<CartItem> list { get; set; } = new List<CartItem>();
public void Add(CartItem item)
{
// Get existing
View gist:34c804a5ea2165b6b4b7380720dea3b7
AddItemToCart: [POST] http://localhost:7071/api/cart/{id}/add
GetCartForSession: [GET] http://localhost:7071/api/cart/{id}
RemoveItemFromCart: [POST] http://localhost:7071/api/cart/{id}/remove