Skip to content

Instantly share code, notes, and snippets.

View LucGosso's full-sized avatar
😀

Luc Gosso LucGosso

😀
View GitHub Profile
using EPiServer;
using EPiServer.Cms.UI.AspNetIdentity;
using EPiServer.Core;
using EPiServer.Logging;
using EPiServer.Notification;
using EPiServer.ServiceLocation;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
@LucGosso
LucGosso / counter.razor
Last active April 14, 2022 13:28
Different razor component approaches
<component type="typeof(Counter)" render-mode="ServerPrerendered"
param-Count="@Model.StartCount" />
___above in cshtml________below in razor____________
@using Microsoft.AspNetCore.Components
<p>Current count: @Count</p>
<button @onclick="IncrementCount" class="btn btn-primary">Click me</button>
using Azure.Storage.Blobs;
public string UploadJsonToAzureBlobStorage(string json)
{
// Name of the share, directory, and file
string shareName = ConfigurationManager.AppSettings.Get("inRiver.StorageAccountShareReference");
string storageAccountName = ConfigurationManager.AppSettings.Get("inRiver.StorageAccountName");
string storageAccountKey = ConfigurationManager.AppSettings.Get("inRiver.StorageAccountKey");
@LucGosso
LucGosso / GetFromAzureFileShare.cs
Last active April 1, 2022 05:48
Example how to access share in azure
using Azure.Storage.Files.Shares;
using Azure.Storage.Files.Shares.Models;
public StockInventory[] GetFromAzureFileShare()
{
// Name of the share, directory, and file
string shareName = ConfigurationManager.AppSettings.Get("inRiver.StorageAccountShareReference");
string storageAccountName = ConfigurationManager.AppSettings.Get("inRiver.StorageAccountName");
string storageAccountKey = ConfigurationManager.AppSettings.Get("inRiver.StorageAccountKey");
@LucGosso
LucGosso / MailToHelper.cs
Last active February 5, 2022 17:37
Mailto email obfuscation helper
using System.Text.RegularExpressions;
namespace Gosso.Mvc.Helpers
{
public class MailToHelper
{
private static readonly string replaceTemplate = @"#"" onclick=""window.location = 'mailto:' + ['{0}'].join(''); return false;";
public static string TransformMailToLinks(string text)
@LucGosso
LucGosso / FeatureConvention.cs
Created November 26, 2021 10:01
ViewEngine code example for featurefolders solutions .net5
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using System;
using System.Linq;
using System.Reflection;
namespace Foundation.Infrastructure.Display
{
public class FeatureConvention : IControllerModelConvention
{
public void Apply(ControllerModel controller)
@LucGosso
LucGosso / PriceJob.cs
Created November 29, 2020 17:36
Properly update price in episerver commerce https://devblog.gosso.se/?p=1486
/// <summary>
/// Iterates the prices from ERP into Episerver Commerce
/// </summary>
/// <param name="variant"></param>
/// <param name="item">Custom Entity from ERP system</param>
private static void AddUpdatePrice(VariationContent variant, PriceMessage item)
{
//no need to delete any prices, IPriceService optimizes the prices from the new prices
var priceService = ServiceLocator.Current.GetInstance<IPriceService>();
List<IPriceValue> priceValues = new List<IPriceValue>();
@LucGosso
LucGosso / ContentRendererService.cs
Created October 27, 2020 21:31
Render Episerver Blocks and ContentArea for use in web api https://devblog.gosso.se/?p=1463
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.Framework.Web;
using EPiServer.Globalization;
using EPiServer.Logging;
using EPiServer.ServiceLocation;
using EPiServer.Web;
using EPiServer.Web.Mvc;
using System.Collections.Generic;
@LucGosso
LucGosso / FeatureFlagService.cs
Last active August 30, 2020 16:28
Simple Feature Flag Service - blob post https://devblog.gosso.se/?p=1410
using AlloyTemplates.Business;
using EPiServer;
using EPiServer.Core;
using EPiServer.Personalization.VisitorGroups;
using EPiServer.ServiceLocation;
using EPiServer.Web;
using System;
using System.Configuration;
using System.Reflection;
using System.Web;
@LucGosso
LucGosso / module.config
Last active February 6, 2020 12:08
Link to containing parent for media and blocks when not used. Blogg post: https://devblog.gosso.se/?p=1291
<?xml version="1.0" encoding="utf-8"?>
<module>
<!--clientResources>
<add name="epi-cms.widgets.base" path="Styles/Styles.css" resourceType="Style"/>
</clientResources-->
<dojo>
<!-- Add a mapping from site to ~/ClientResources/Scripts to the dojo loader configuration -->
<paths>
<add name="clientscripts" path="Scripts" />
</paths>