This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EntityController : ApiController | |
{ | |
public SomeDto Get() | |
{ | |
//return some DTO | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomerValidator: AbstractValidator | |
{ | |
public CustomerValidator() | |
{ | |
RuleFor(customer => customer.Surname).NotEmpty(); | |
RuleFor(customer => customer.Forename).NotEmpty().WithMessage("Please specify a first name"); | |
RuleFor(customer => customer.Discount).NotEqual(0).When(customer => customer.HasDiscount); | |
RuleFor(customer => customer.Address).Length(20, 250); | |
RuleFor(customer => customer.Postcode).Must(BeAValidPostcode).WithMessage("Please specify a valid postcode"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IQueryable<CustomerPurchases> GetPurchases(int customerID) | |
{ | |
return _purchaseService.GetPurchases(customerID); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Color | |
{ | |
public double Red { get; set; } | |
public double Green { get; set; } | |
public double Blue { get; set; } | |
public Color() | |
{ } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class APIKeyHandler : DelegatingHandler | |
{ | |
private const string REQUEST_HEADER = "X-KARBYN-APIKEY"; | |
protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
{ | |
bool isValidAPIKey = false; | |
//Validate that the api key exists, and if so, validate | |
if (request.Headers.Contains(REQUEST_HEADER)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override void OnException(HttpActionExecutedContext actionExecutedContext) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace StrategyPattern.Contracts | |
{ | |
public interface IDiscountStrategy | |
{ | |
decimal ApplyDiscount(decimal price); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// Updates the datasource for a rendering from an item path to using the | |
/// Sitecore ID for the item. The benefit is that this will allow datasources | |
/// to be able to be freely moved from one area of the content tree to another | |
/// while enabling the rendering to still function as expected. | |
/// | |
///The Sitecore.Data.Items.Item to update the datasources for. | |
public void UpdateDataSourcePathToId(Sitecore.Data.Items.Item itemToProcess) | |
{ | |
if (null != itemToProcess) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using Sitecore.Rules; | |
using Sitecore.Rules.Conditions; | |
using Sitecore.Data.Items; | |
using Sitecore.Analytics; | |
using Karbyn.SC.Core.Extensions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using System.Security.Claims; | |
using System.Threading.Tasks; | |
using Microsoft.IdentityModel.Protocols; | |
using Microsoft.Owin.Security; | |
using Microsoft.Owin.Security.Notifications; | |
using Microsoft.Owin.Security.OpenIdConnect; | |
using Owin; | |
using Sitecore.Owin.Authentication.Configuration; | |
using Sitecore.Owin.Authentication.Pipelines.IdentityProviders; |
OlderNewer