Skip to content

Instantly share code, notes, and snippets.

View mattbrailsford's full-sized avatar

Matt Brailsford mattbrailsford

View GitHub Profile
internal class OrderStatusRepository : RepositoryBase, IOrderStatusRepository
{
private IDatabaseUnitOfWork _uow;
public OrderStatusRepository(IDatabaseUnitOfWork uow)
{
_uow = uow;
}
public IEnumerable<OrderStatusState> GetAll()
@mattbrailsford
mattbrailsford / PriceBreakOrderLineCalculator.cs
Last active May 3, 2022 13:02
Example order line calculator that support price breaks
using System;
using System.Collections.Generic;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web;
using Vendr.Core.Calculators;
using Vendr.Core.Models;
using Vendr.Core.Services;
using Vendr.Web.Models;
namespace Vendr.DemoStore.Web.Calculators
using System.Web.Http;
using Umbraco.Core.Cache;
using Umbraco.Web;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
using Umbraco.Web.Cache;
using Umbraco.Core.Services.Changes;
namespace Our.Umbraco.Web.Controllers
{
@mattbrailsford
mattbrailsford / OrderServiceExtensions.cs
Last active August 21, 2020 08:40
Vendr extension to get all orders for a customer
using System;
using System.Collections.Generic;
using System.Linq;
using Vendr.Core;
using Vendr.Core.Api;
using Vendr.Core.Models;
using Vendr.Core.Services;
namespace VendrExt
{
{
"$schema": "https://raw.githubusercontent.com/nuke-build/nuke/master/source/Nuke.CodeGeneration/schema.json",
"name": "UmbPack",
"officialUrl": "https://github.com/umbraco/UmbPack",
"help": "UmbPack is a CLI tool to use in CI/CD to upload Umbraco .zip packages to the our.umbraco.com package repository.",
"packageId": "Umbraco.Tools.Packages",
"packageExecutable": "UmbPack.dll",
"tasks": [
{
"postfix": "Pack",
@mattbrailsford
mattbrailsford / Links.txt
Last active April 26, 2023 12:18
Master branch naming research
using Vendr.Core.Models;
using Vendr.Core.Services;
using Vendr.Core.Templating;
namespace Vendr.Core.Pipelines.Email.Tasks
{
public class RenderEmailTemplateTask : PipelineTaskWithTypedArgsBase<EmailSendPipelineArgs, EmailContext>
{
private ITranslationService _translationService;
private IEmailTemplateEngine _emailTemplateEngine;
@mattbrailsford
mattbrailsford / FacetedSearch.cs
Created June 3, 2020 18:07
Vendr Faceted Search
// Perform a faceted search based on product categories
var dir = new DirectoryInfo(((LuceneIndex)index).LuceneIndexFolder.FullName);
using (var searcher = new IndexSearcher(FSDirectory.Open(dir), false))
using (var factedSearcher = new SimpleFacetedSearch(searcher.IndexReader, new string[] { "searchCategory" }))
{
var queryParser = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer());
var query = queryParser.Parse(sb.ToString());
var queryResults = factedSearcher.Search(query, ps * p);
var facetedResults = new Dictionary<string, PagedResult<IPublishedContent>>();
setTimeout(function() {
var form = document.getElementById("paymentForm");
if (form.hasAttribute("onsubmit")) {
form.dispatchEvent(new Event('submit', { cancelable: true }));
} else {
form.submit();
}
}, 100)
var bundleId = "MyBundle";
// Create a bundle
order.AddProduct("product-ref", 1, bundleId);
// Add a products to a bundle
order.AddProductToBundle(bundleId, "sub-product-ref1", 1);
order.AddProductToBundle(bundleId, "sub-product-ref2", 1);