title: When mapping (automapper) need to convert a type enum to a bool
body: <p>I have the following <strong>model</strong>: </p>
  
  <pre><code>public class Foo
  {
      [Key]
      public int      FooID { get; set; }
      public string   Description { get; set; }
      public bool     IsValid{ get; set; }
  }
  </code></pre>
  
  <p>I have the following <strong>view model</strong>:</p>
  
  <pre><code>public class FooViewModel
  {
      public int FooId { get; set; }
      public string Description { get; set; }
      public YesNoEnumViewModel IsValid{ get; set; }
  }
  </code></pre>
  
  <p>For the type YesNoEnumViewModel I used the following enum:</p>
  
  <pre><code>public enum YesNoEnumViewModel
  {
      [Display(Name = "Yes", ResourceType = typeof(UserResource))]
      Yes = 1,
      [Display(Name = "No", ResourceType = typeof(UserResource))]
      No = 2
  }
  </code></pre>
  
  <p>In my code I need to map my viewModel into my model. So I try this:</p>
  
  <pre><code>    [HttpPost]
      public ActionResult AddedNew(FooViewModel viewModel)
      {
          if (!ModelState.IsValid)
              return PartialView("AddedNew", viewModel);
  
          var foo = Mapper.Map&lt;FooViewModel, FooModel&gt;(viewModel);
          ...
      }
  </code></pre>
  
  <p>And I got an error when trying to map. The error is on the converting from the enum type YesNoEnumViewModel to bool (the property in my model is of type bool).</p>
  
  <p>Here is my CreateMap:</p>
  
  <pre><code>Mapper.CreateMap&lt;FooViewModel, Foo&gt;();
  </code></pre>
  
  <p>Maybe I need to specify in the CreateMap that for member <strong>IsValid</strong> of my FooViewModel something special must be done to convert it to a bool of my model?</p>
  
  <p>Thanks for your help.</p>