Skip to content

Instantly share code, notes, and snippets.

@Fodsuk
Fodsuk / gist:1125320
Created August 4, 2011 14:45
a tiny bit shorter
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BackOffice.WebUI.Controllers.Base;
using Watchfinder.Commands.Marketing.Channels;
using Watchfinder.Reads.Marketing;
using Watchfinder.Reads.Marketing.Views;
@Fodsuk
Fodsuk / gist:1466718
Created December 12, 2011 11:28
PPS Command triggers
//scheduled trigger - one of execution
public class ScheduledTrigger : ITrigger
{
public ScheduledTrigger() { }
public ScheduledTrigger(DateTime date)
{
Date = date;
}
@Fodsuk
Fodsuk / gist:2406528
Created April 17, 2012 14:57
[usp_CashOfferSELECTNew]
USE [NewBusiness]
GO
/****** Object: StoredProcedure [dbo].[usp_CashOfferSELECTNew] Script Date: 04/17/2012 14:53:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
@Fodsuk
Fodsuk / gist:2836453
Created May 30, 2012 13:52
WorkflowController
public abstract class WorkflowController : BaseController
{
private string _workflowReference;
private readonly string _modelNamespace;
private readonly string _modelAssembly;
private IWorkflowKeyStore _workflowKeyStore;
private IWorkflowInvokerFactory _invokerFactory;
protected WorkflowController(string workflowReference, string modelNamespace, string modelAssembly, IWorkflowKeyStore workflowKeyStore, IWorkflowInvokerFactory workflowInvokerFactory)
{
@Fodsuk
Fodsuk / gist:2836457
Created May 30, 2012 13:52
Application workflow controller
public class ApplicationController : WorkflowController
{
public ApplicationController(IWorkflowKeyStore workflowKeyStore, IWorkflowInvokerFactory workflowInvokerFactory)
: base("face2face", "Vanquis.NewBusiness.PL.Models", "Vanquis.NewBusiness.PL.Models", workflowKeyStore, workflowInvokerFactory) { }
[NoCache]
[Authorize]
public ActionResult Index()
{
LogSystem.log.Debug("ApplicationController/Index");
@Fodsuk
Fodsuk / gist:3025099
Created June 30, 2012 18:56
service layer exampe
public class InventoryController : ApiController
{
private readonly IInventoryManagementService _inventoryManagementService;
private readonly IUnitOfWork _unitOfWork;
public InventoryController(IUnitOfWork unitOfWork)
{
_unitOfWork = unitOfWork; //access services
_inventoryManagementService = _unitOfWork.Get<IInventoryManagementService>();
}
@Fodsuk
Fodsuk / gist:3129520
Created July 17, 2012 13:57
Json Serialisation
public class JsonSerialiser : ISerialiser
{
public string Serialize<T>(T t)
{
var ser = new DataContractJsonSerializer(typeof(T));
var ms = new MemoryStream();
ser.WriteObject(ms, t);
string jsonString = Encoding.UTF8.GetString(ms.ToArray());
ms.Close();
public class CardValidationService : ICardValidationService
{
private readonly CallValidationConfiguration _config;
private readonly ICallValidateDataService _callValidateDataService;
private readonly ILogger _logger = LoggerProvider.GetLogger<CardValidationService>();
public CardValidationService(CallValidationConfiguration config, ICallValidateDataService callValidateDataService)
{
_config = config;
_callValidateDataService = callValidateDataService;
public bool ValidateExpiryDate(string cardExpiryDate, DateTime lastPaymentDate)
{
if (cardExpiryDate == null || !CardDateUtil.FormatIsValid(cardExpiryDate)) return false;
DateTime expiryDate = CardDateUtil.ConvertToDateTime(cardExpiryDate, SetDayOfMonth.LastDayOfMonth);
var invalidExpiryDate = lastPaymentDate.AddMonths(3); //TODO: pass as variable
var inDate = expiryDate >= invalidExpiryDate;
public class CardValidationService : ICardValidationService
{
private readonly CallValidationConfiguration _config;
private readonly ICallValidateDataService _callValidateDataService;
private readonly ILogger _logger = LoggerProvider.GetLogger<CardValidationService>();
public CardValidationService(CallValidationConfiguration config, ICallValidateDataService callValidateDataService)
{
_config = config;
_callValidateDataService = callValidateDataService;