|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Demo.Data;
using AutoMapper;
using Demo.Core.Models;
using Demo.Framework;
namespace Demo.Core
{
public class HandlerMaterial : BaseHandler<MaterialView, Material>
{
public HandlerMaterial()
: base(DemoRepository<Material>.Instance)
{
new HandlerTag();
}
protected override Type LogPrefix
{
get { return this.GetType(); }
}
public override void ForwardMap(IMappingExpression<MaterialView, Material> mappingExpression)
{
mappingExpression
.ForMember(dest => dest.MaterialId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.TagId, opt => opt.MapFrom(src => src.SelectedTag.Id))
.ForMember(dest => dest.AdditionalData, opt => opt.MapFrom(src => (src.Data != null) ? src.Data.ToString() : ""));
}
public override void BackwardMap(IMappingExpression<Material, MaterialView> mappingExpression)
{
mappingExpression
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.MaterialId))
.ForMember(dest => dest.SelectedTag, opt => opt.MapFrom(src => Mapper.Map<Tag, TagView>(src.Tag)))
.ForMember(dest => dest.Data, opt => opt.MapFrom(src => AdditionalData.Resolve(src.AdditionalData)));
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
In-depth coverage of Microsoft .Net, Cloud and many other cutting-edge Technologies.
-
The Mandelbrot set – someone has called it the thumb-print of God – is one of the most beautiful and remarkable discoveries in the entire history of mathematics. My profile picture is generated with that equation.
You may contact Nirosh for Consultations, Code Reviews and Architecture Guide Workshops via c_nir*o*sh@hotmail.com (Remove * to use)
View Nirosh L.W.C.'s profile on LinkedIn
Other Links