This file contains hidden or 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 CsvFormatter : ICsvFormatter | |
{ | |
public void Export(Report report) | |
{ | |
Console.WriteLine($"CsvFormatter.Export: {report.Name}"); | |
} | |
} | |
public interface ICsvFormatter | |
{ |
This file contains hidden or 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 BaseTest | |
{ | |
protected Mock<IProductLogic> Logic { get; set; } | |
protected Mock<IMapper> Mapper { get; set; } | |
protected virtual ProductsController Create() | |
{ | |
Logic = new Mock<IProductLogic>(); |
This file contains hidden or 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 BaseTests : RepositoryTests | |
{ | |
protected ProductRepository Create(string path = null) | |
{ | |
var context = CreateContext(path); | |
return new ProductRepository(new Lazy<DataContext>(() => context)); | |
} | |
} |
This file contains hidden or 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 GetByIdTests : BaseTest | |
{ | |
protected Mock<IProductRepository> Repository { get; private set; } | |
protected ProductLogic Create() | |
{ | |
Repository = new Mock<IProductRepository>(); | |
return new ProductLogic(new Lazy<IProductRepository>(() => Repository.Object)); | |
} |
This file contains hidden or 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 BaseModel | |
{ | |
public BaseModel() | |
{ | |
IsActive = true; | |
} | |
public int Id { get; set; } | |
public bool IsActive { get; set; } |
This file contains hidden or 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
@model PartialForms.ViewModels.Shared.AddressViewModel | |
<div class="form-group"> | |
@Html.LabelFor(model => model.Street, htmlAttributes: new { @class = "control-label col-md-2" }) | |
<div class="col-md-10"> | |
@Html.EditorFor(model => model.Street, new { htmlAttributes = new { @class = "form-control" } }) | |
@Html.ValidationMessageFor(model => model.Street, "", new { @class = "text-danger" }) | |
</div> | |
</div> |
This file contains hidden or 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 static class ControllerExtensions | |
{ | |
public static string GetUserClaim(this ApiController controller, string claimName) | |
{ | |
var principal = controller.User as ClaimsPrincipal; | |
if (principal == null) | |
{ | |
return null; | |
} |
This file contains hidden or 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
/// <summary> | |
/// The product. | |
/// </summary> | |
public class Product | |
{ | |
/// <summary> | |
/// Gets or sets the identifier. | |
/// </summary> | |
/// <value> | |
/// The identifier. |
This file contains hidden or 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
CREATE TABLE [dbo].[Categories] ( | |
[Id] INT NOT NULL IDENTITY(1,1), | |
[Name] NVARCHAR(255) NOT NULL, | |
CONSTRAINT [PK_Categories] PRIMARY KEY ([Id]) | |
) | |
INSERT INTO dbo.Categories SELECT DISTINCT Category FROM dbo.Products; | |
ALTER TABLE [dbo].[Products] ADD [CategoryId] INT |
This file contains hidden or 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
[Migration(201810030717)] | |
public class AddCategory : Migration | |
{ | |
public override void Up() | |
{ | |
Create.Table("Categories") | |
.WithColumn("Id").AsInt32().NotNullable().PrimaryKey().Identity() | |
.WithColumn("Name").AsString(); | |
Execute.Sql("INSERT INTO dbo.Categories SELECT DISTINCT Category FROM dbo.Products;"); |