I have the following problem with FastMapper. When implementing an ActionResult async when using the TypeAdapt it can not perform the asynchronous conversion, would anyone know how to do the conversion with FastMapper? Remember, when I do the conversion on hand and or without async the same works normally. Code that presents the problem:
// GET: Credito/Details/5
public async Task<ActionResult> Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
var creditoTabela = db.Creditos.FindAsync(id);
CreditoViewModel creditoTela = await TypeAdapter.Adapt<CreditoModel, CreditoViewModel> (creditoTabela);
if (creditoTela == null)
{
return HttpNotFound();
}
return View(creditoTela);
}
Validation and error image:
ErrorMessage:
Without using FastMapper it works normally, my problem is how to use FastMapper with Async? Do I have to implement anything in the part of the Model in order to work?
// GET: Credito/Details/5
public async Task<ActionResult> Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
var creditoTabela = db.Creditos.Find(id);
CreditoViewModel creditoTela = new CreditoViewModel() {
Codigo = creditoTabela.Codigo,
Descricao = creditoTabela.Descricao,
Nome = creditoTabela.Nome,
Imagem = creditoTabela.Imagem
};
if (creditoTela == null)
{
return HttpNotFound();
}
return View(creditoTela);
}