public MapperFactory() { Mapper.Initialize(config => { config.CreateMap <Evento, ItemEvento>() .ForMember(d => d.Titulo, s => s.MapFrom(src => src.Nome)) .ForMember(d => d.Local, s => s.MapFrom(scr => $"{scr.Logradouro},{scr.Numero} - {scr.Bairro} - {scr.Cidade}")); config.CreateMap <Usuario, ApplicationUserTO>() .ConstructUsing(d => new ApplicationUserTO() { Email = d.Email, UserName = d.Email, Password = d.Password, Claims = ApplicationUserTO.CreateClaimsFrom <Usuario>(d) }); config.CreateMap <Empresa, ApplicationUserTO>() .ConstructUsing(d => new ApplicationUserTO() { Email = d.Email, UserName = d.Email, Password = d.Password, Claims = ApplicationUserTO.CreateClaimsFrom <Empresa>(d) }); config.CreateMap <Compra, ItemCompra>() .ForMember(d => d.Titulo, s => s.MapFrom(c => c.Descricao)) .ForMember(d => d.CodEvento, s => s.MapFrom(c => c.ItemID)); config.CreateMissingTypeMaps = true; }); }
public async Task <IActionResult> PostEmpresaAsync([FromBody] ApplicationUserTO applicationUser) { var usuario = new ApplicationUser() { Email = applicationUser.Email, UserName = applicationUser.UserName, Claims = applicationUser.Claims }; usuario.Claims.Add(new MyClaim("tipo", "empresa")); try { usuario = await _applicationUserDados.AddAsync(usuario, applicationUser.Password); } catch (System.Exception ex) { return(BadRequest($"não foi possivel cadastrar Erro[{ex.Message}]")); } return(Ok(usuario)); }