Skip to content

Instantly share code, notes, and snippets.

View rmaziarka's full-sized avatar

Radek Maziarka rmaziarka

View GitHub Profile
(function () {
angular.module('moduleName').directive('kendoGridRowDblClick', kendoGridRowDblClick);
function kendoGridRowDblClick() {
return {
link: function (scope, element, attrs) {
scope.$on("kendoWidgetCreated", function (event, widget) {
if (widget !== element.getKendoGrid())
return;
public class Requirement : BaseEntity
{
public DateTime CreateDate { get; set; }
public decimal? MinPrice { get; set; }
public decimal? MaxPrice { get; set; }
public ICollection<Contact> Contacts { get; set; }
public Country Country { get; set; }
}
@rmaziarka
rmaziarka / Resolver_with_proper_order.cs
Created February 11, 2017 12:20
Resolver with proper order
public class Resolver : IValueResolver<object, object, int?>, IValueResolver<object, object, int>
{
public int? Resolve(object source, object destination, int? destMember, ResolutionContext context)
{
var result = SomeLogic(source);
return result;
}
public int Resolve(object source, object destination, int destMember, ResolutionContext context)
@rmaziarka
rmaziarka / Resolver_with_improper_order.cs
Created February 11, 2017 12:24
Resolver with improper order
public class Resolver : IValueResolver<object, object, int>, IValueResolver<object, object, int?>
{
public int? Resolve(object source, object destination, int? destMember, ResolutionContext context)
{
var result = SomeLogic(source);
return result;
}
public int Resolve(object source, object destination, int destMember, ResolutionContext context)
@rmaziarka
rmaziarka / Automapper_CreateMissingTypeMaps_true.cs
Last active March 14, 2017 22:09
Map with CreateMissingTypeMaps flag set
void Main()
{
Mapper.Initialize(cfg =>
{
cfg.CreateMissingTypeMaps = true;
cfg.AddProfile(new DestinationProfile());
});
var source = new Source();
var destination = new Destination() { Flag = false };
@rmaziarka
rmaziarka / Automapper_CreateMissingTypeMaps_false.cs
Last active March 14, 2017 22:09
Map with CreateMissingTypeMaps flag unset
void Main()
{
Mapper.Initialize(cfg =>
{
cfg.CreateMissingTypeMaps = false;
cfg.AddProfile(new DestinationProfile());
});
var source = new Source();
var destination = new Destination() { Flag = false };
@rmaziarka
rmaziarka / ProductVm.cs
Last active October 31, 2017 12:53
CQRS - Second step - Simple read model - Product view model
public class ProductVm
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public string CategoryName { get; set; }
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public DateTime CreationDate { get; set; }
public class ProductAddedEvent : INotification
{
public ProductAddedEvent(int id, string name, int categoryId)
{
Id = id;
Name = name;
CategoryId = categoryId;
}
public int Id { get; }
public class AddProductCommandHandler : IRequestHandler<AddProductCommand>
{
private readonly ProductDatabase _database;
private readonly IMediator _mediator;
public AddProductCommandHandler(ProductDatabase database, IMediator mediator)
{
_database = database;
_mediator = mediator;
}