Skip to content

Instantly share code, notes, and snippets.

View prjseal's full-sized avatar
🏠
Working from home

Paul Seal prjseal

🏠
Working from home
View GitHub Profile
@prjseal
prjseal / EditorModelEventsComposer.cs
Created January 18, 2022 09:19
Hide Properties in Umbraco 8
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Web.Editors;
namespace CodeShare.Core.Composing
{
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
public class EditorModelEventsComposer : ComponentComposer<EditorModelEventsComponent>
{
@prjseal
prjseal / MemberSearch.cs
Last active December 8, 2020 13:47
Get members using Examine
public IEnumerable<ISearchResult> GetMembersByKeys(string[] memberKeys)
{
if (ExamineManager.Instance.TryGetIndex(Constants.UmbracoIndexes.MembersIndexName, out var index))
{
var searcher = index.GetSearcher();
var criteria = searcher.CreateQuery();
var query = criteria.GroupedOr(new[] { "__Key" }, memberKeys);
var searchResults = query.Execute();
return searchResults;
}

Episode 11

Facebook Group

LiveAppData

<Compile Include="App_Data\Models\*.generated.cs" />
@prjseal
prjseal / file1.json
Created January 24, 2019 15:20
Multi file gist example
{name: "This is the first file"}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<clear />
<add name="DOCX" path="*.docx" verb="*" type="CodeShare.Web.Handlers.MediaHandler" />
<add name="XLSX" path="*.xlsx" verb="*" type="CodeShare.Web.Handlers.MediaHandler" />
<add name="DOC" path="*.doc" verb="*" type="CodeShare.Web.Handlers.MediaHandler" />
<add name="XLS" path="*.xls" verb="*" type="CodeShare.Web.Handlers.MediaHandler" />
<add name="PDF" path="*.pdf" verb="*" type="CodeShare.Web.Handlers.MediaHandler" />
using System.Linq;
using System.Web.Http;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Web.WebApi;
namespace CodeShare.Web.Controllers.ApiControllers
{
public class ProtectedMediaApiController : UmbracoApiController
{
using CodeShare.Library.Helpers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Web;
namespace CodeShare.Web.Handlers
{
public class MediaHandler : IHttpHandler
{
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace CodeShare.Library.Helpers
{
public class ApiHelper
@prjseal
prjseal / 10.cs
Last active June 15, 2017 12:59
NINumberValidator
using System.Collections.Generic;
namespace NINumberValidator
{
public class NIValidator
{
public bool IsValid(string niNumber)
{
bool isValid = false;
if(!string.IsNullOrEmpty(niNumber))
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Linq
@{
var blogPostList = Model.Content.Parent;
IEnumerable<dynamic> allPosts = blogPostList.Children.Where("Visible");
List<int> ids = allPosts.Select(x => (int)x.Id).ToList();
int indexOfThisPost = ids.IndexOf(Model.Content.Id);
bool isLast = (indexOfThisPost >= ids.Count() - 1);