Added ServiceController
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
using AutoMapper;
|
||||
using Birdmap.API.DTOs;
|
||||
using Birdmap.DAL.Entities;
|
||||
using System;
|
||||
|
||||
namespace Birdmap.API.MapperProfiles
|
||||
{
|
||||
@ -7,10 +9,31 @@ namespace Birdmap.API.MapperProfiles
|
||||
{
|
||||
public BirdmapProfile()
|
||||
{
|
||||
CreateMap<User, DTOs.AuthenticateResponse>()
|
||||
CreateMap<Uri, string>().ConvertUsing<UriToStringConverter>();
|
||||
CreateMap<string, Uri>().ConvertUsing<UriToStringConverter>();
|
||||
|
||||
CreateMap<User, AuthenticateResponse>()
|
||||
.ForMember(m => m.Username, opt => opt.MapFrom(m => m.Name))
|
||||
.ForMember(m => m.UserRole, opt => opt.MapFrom(m => m.Role))
|
||||
.ReverseMap();
|
||||
|
||||
CreateMap<Service, ServiceRequest>()
|
||||
.ReverseMap();
|
||||
}
|
||||
|
||||
private class UriToStringConverter : ITypeConverter<Uri, string>, ITypeConverter<string, Uri>
|
||||
{
|
||||
public string Convert(Uri source, string destination, ResolutionContext context)
|
||||
{
|
||||
destination = source.ToString();
|
||||
return destination;
|
||||
}
|
||||
|
||||
public Uri Convert(string source, Uri destination, ResolutionContext context)
|
||||
{
|
||||
Uri.TryCreate(source, UriKind.Absolute, out destination);
|
||||
return destination;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user