DNNCommunity / DNN.Faq

DNN FAQ is a basic module used for displaying frequently asked questions on your DNN site.
https://dnncommunity.github.io/DNN.Faq/
MIT License
17 stars 20 forks source link

Import failing when reading Null Date for ExpireDate #17

Closed swkuhn closed 6 years ago

swkuhn commented 8 years ago

In v 5.1.1, when importing a module saved with the 5.0.2 version of FAQ, an exception is thrown. This is due to a Null.NullDate previously saved as the ExpireDate.

The fix is in the controller import, add a check for Null.NullDate

// These dates might be emtpy
try
{
    faq.PublishDate = DateTime.Parse(xFaq.Element("publishdate").Value);
    if (faq.PublishDate.HasValue && faq.PublishDate.Value == Null.NullDate)
    {
          faq.PublishDate = null;
    }
 }
 catch (Exception)
 {
    faq.PublishDate = null;
 }

try
{
   faq.ExpireDate = DateTime.Parse(xFaq.Element("expiredate").Value);
   if (faq.ExpireDate.HasValue && faq.ExpireDate.Value == Null.NullDate)
   {
      faq.ExpireDate = null;
   }
}

catch (Exception)
{
    faq.ExpireDate = null;
}