Skip to content

Instantly share code, notes, and snippets.

@evgomes
Created February 4, 2019 22:34
Show Gist options
  • Save evgomes/e1594501f7072d4a1dd785962af8da17 to your computer and use it in GitHub Desktop.
Save evgomes/e1594501f7072d4a1dd785962af8da17 to your computer and use it in GitHub Desktop.
ModelToResourceProfile with product mapping, of Supermarket API
using AutoMapper;
using Supermarket.API.Domain.Models;
using Supermarket.API.Extensions;
using Supermarket.API.Resources;
namespace Supermarket.API.Mapping
{
public class ModelToResourceProfile : Profile
{
public ModelToResourceProfile()
{
CreateMap<Category, CategoryResource>();
CreateMap<Product, ProductResource>()
.ForMember(src => src.UnitOfMeasurement,
opt => opt.MapFrom(src => src.UnitOfMeasurement.ToDescriptionString()));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment