I have searched on Stack Overflow and googled about it but I haven\'t been able to find any help or suggestion on this.
I have a class like the following which create a <
This is a best practice:
first step: create a generice class.
public class AutoMapperGenericsHelper
{
public static TDestination ConvertToDBEntity(TSource model)
{
Mapper.CreateMap();
return Mapper.Map(model);
}
}
Second step: Do Use it
[HttpPost]
public HttpResponseMessage Insert(LookupViewModel model)
{
try
{
EducationLookup result = AutoMapperGenericsHelper.ConvertToDBEntity(model);
this.Uow.EducationLookups.Add(result);
Uow.Commit(User.Id);
return Request.CreateResponse(HttpStatusCode.OK, result);
}
catch (DbEntityValidationException e)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError, CustomExceptionHandler.HandleDbEntityValidationException(e));
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.BadRequest, ex.HResult.HandleCustomeErrorMessage(ex.Message));
}
}