Fixes U4-2822 Datepicker throws "Specified cast is not valid" when saving through API

This commit is contained in:
Morten Christensen
2013-09-18 10:06:08 +02:00
parent 95df28bf64
commit dc1a67bfa2
2 changed files with 13 additions and 6 deletions

View File

@@ -65,12 +65,12 @@ namespace Umbraco.Core.Models.Rdbms
return Date.Value;
}
if(!string.IsNullOrEmpty(VarChar))
if(string.IsNullOrEmpty(VarChar) == false)
{
return VarChar;
}
if(!string.IsNullOrEmpty(Text))
if(string.IsNullOrEmpty(Text) == false)
{
return Text;
}

View File

@@ -11,10 +11,17 @@ namespace umbraco.editorControls.datepicker
public override System.Xml.XmlNode ToXMl(System.Xml.XmlDocument d)
{
if (Value != null && Value.ToString() != "")
return d.CreateTextNode(((DateTime) Value).ToString("s"));
else
return d.CreateTextNode("");
if (Value != null && Value.ToString() != "")
{
if(Value is DateTime)
return d.CreateTextNode(((DateTime) Value).ToString("s"));
DateTime convertedDate;
if (DateTime.TryParse(Value.ToString(), out convertedDate))
return d.CreateTextNode(convertedDate.ToString("s"));
}
return d.CreateTextNode("");
}
public override void MakeNew(int PropertyId)