public static webModels.NotificationParameter ToWebModel(this coreModels.NotificationParameter notificationParameter) { webModels.NotificationParameter retVal = new webModels.NotificationParameter(); retVal.InjectFrom(notificationParameter); return(retVal); }
public static webModels.NotificationParameter ToWebModel(this coreModels.NotificationParameter notificationParameter) { webModels.NotificationParameter retVal = new webModels.NotificationParameter(); retVal.InjectFrom(notificationParameter); return retVal; }
private void SetValue(Notification notification, webModels.NotificationParameter param) { var property = notification.GetType().GetProperty(param.ParameterName); var jObject = param.Value as Newtonsoft.Json.Linq.JObject; var jArray = param.Value as Newtonsoft.Json.Linq.JArray; if (jObject != null && param.IsDictionary) { property.SetValue(notification, jObject.ToObject <Dictionary <string, string> >()); } else { switch (param.Type) { case NotificationParameterValueType.Boolean: if (jArray != null && param.IsArray) { property.SetValue(notification, jArray.ToObject <Boolean[]>()); } else { property.SetValue(notification, param.Value.ToNullable <Boolean>()); } break; case NotificationParameterValueType.DateTime: if (jArray != null && param.IsArray) { property.SetValue(notification, jArray.ToObject <DateTime[]>()); } else { property.SetValue(notification, param.Value.ToNullable <DateTime>()); } break; case NotificationParameterValueType.Decimal: if (jArray != null && param.IsArray) { property.SetValue(notification, jArray.ToObject <Decimal[]>()); } else { property.SetValue(notification, Convert.ToDecimal(param.Value)); } break; case NotificationParameterValueType.Integer: if (jArray != null && param.IsArray) { property.SetValue(notification, jArray.ToObject <Int32[]>()); } else { property.SetValue(notification, param.Value.ToNullable <Int32>()); } break; case NotificationParameterValueType.String: if (jArray != null && param.IsArray) { property.SetValue(notification, jArray.ToObject <String[]>()); } else { property.SetValue(notification, (string)param.Value); } break; default: if (jArray != null && param.IsArray) { property.SetValue(notification, jArray.ToObject <String[]>()); } else { property.SetValue(notification, (string)param.Value); } break; } } }