Skip to content

Instantly share code, notes, and snippets.

public class MyModel {
public string Prop1 { get; set; }
public string Prop2 { get; set; }
[DataType.Date]
public string Prop3 { get; set; }
@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>();
}
{
"data": {
"mobile_numbers": [
{ "number": "+44 (0)07779288893" },
{ "number": "+44 (0)07779288893" }
],
"email_addresses": [
{"address":"me@there.com"},
{"address":"you@there.com"}
using FluentValidation;
using FluentValidation.Results;
using Vanquis.Digital.Services.WebAPI.Requests;
using Microsoft.Extensions.Options;
using Vanquis.Digital.Services.WebAPI.Helper;
namespace Vanquis.Digital.Services.WebAPI.ModelValidators
{
public class TransactionRequestValidator : AbstractValidator<TransactionsRequest>
{
public async Task Invoke(HttpContext context)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
context.Response.OnStarting(_ =>
{
((HttpContext)_).Response.Headers["X-Instrumentation-Time-Elapsed-Ms"] = stopWatch.ElapsedMilliseconds.ToString();
return Task.FromResult(0);
}, context);
@Fodsuk
Fodsuk / gist:5254318
Created March 27, 2013 13:55
alot to do
public void SendTemplate(/* to decide: TemplateId, Parameters */)
{
/*
- Get any flow with this template (Flow name, Flow Parameters)
- Get FlowOrderId of template on Flow
- Update Flow parameter values with parameters passed by user
- Update special parameters (email, sms)
- CreateSchedule
- Send Schedule for particular template
@Fodsuk
Fodsuk / gist:5246100
Created March 26, 2013 15:10
Getting better
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Vanquis.Services.Communication.Contracts.ServiceContracts
{
//Templates
public interface ITemplateService
ProspectBasedUserAuthenticationService
2) Injection of dependency IUserAuthenticationService into parameter authenticationService of constructor of type UsersController
1) Request for UsersController
Suggestions:
public static IMappingExpression<TSource, TDestination> IgnoreAllNonExisting<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
{
var sourceType = typeof(TSource);
var destinationType = typeof(TDestination);
var existingMaps = Mapper.GetAllTypeMaps();
var first = existingMaps.First(x => x.SourceType == sourceType && x.DestinationType == destinationType);
foreach (var property in first.GetUnmappedPropertyNames())
{
namespace Vanquis.NewBusiness.Loans.Services.Tests.Utils
{
public class ExpectArugmentNullExceptionAttribute : ExpectedExceptionAttribute
{
public ExpectArugmentNullExceptionAttribute(string message)
: base(typeof(ArgumentNullException))
{
ExpectedMessage = message;
MatchType = MessageMatch.Contains;