Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SharePointRepository.cs #13

Merged
merged 1 commit into from Feb 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 17 additions & 10 deletions Enmarcha.SharePoint/Entities/Data/SharePointRepository.cs
Expand Up @@ -221,19 +221,19 @@ private void GetValue(SPListItem listItem, PropertyInfo prop, T valor)
}
}

private void SetDefault(SPListItem listItem, PropertyInfo prop, T valor, string nameInternal, string type, bool multiple)
private void SetDefault(SPListItem listItem, PropertyInfo prop, T valor, string nameInternal, string type, bool multiple)
{
try
{
var field = listItem.Fields.GetFieldByInternalName(nameInternal);
var fieldValueType = field.FieldValueType.Name;
var fieldValueType = field.FieldValueType !=null ? field.FieldValueType.Name : field.TypeAsString;
if (fieldValueType.Contains("Boolean"))
{
SetFieldBoolean(listItem, prop, valor, nameInternal);
return;
}

if (fieldValueType.Contains("Double"))
if (fieldValueType.Contains("Double") || fieldValueType.Contains("Counter"))
{
SetFieldDouble(listItem, prop, valor, type, nameInternal);
return;
Expand All @@ -246,22 +246,29 @@ private void SetDefault(SPListItem listItem, PropertyInfo prop, T valor, string
if (fieldValueType.Contains("Url"))
{
SetFieldUrl(listItem, prop, valor, nameInternal);
return;
}
if (fieldValueType.Contains("User"))
{
SetFieldTypeUSer(listItem, prop, valor, nameInternal, multiple);
}
else
{
SetFieldTypeDefault(listItem, prop, valor, nameInternal);
return;
}

SetFieldTypeDefault(listItem, prop, valor, nameInternal);
}
catch (Exception exception)
{
Logger.Warn("Aviso" + exception.Message);
prop.SetValue(valor,
(listItem[nameInternal] != null ? listItem[nameInternal].ToString() : ""));
Logger.Warn("Aviso " + exception.Message);
try
{
prop.SetValue(valor,
(listItem[nameInternal] != null ? listItem[nameInternal].ToString() : ""));
}
catch (Exception ex)
{
Logger.Error(ex.Message);
}

}
}

Expand Down