public static string GetValue(FieldInfo fieldInfo, LogInfo logInfo) { var value = string.Empty; if (logInfo.ContainsKey(fieldInfo.Title)) { if (fieldInfo.FieldType == InputType.CheckBox.Value || fieldInfo.FieldType == InputType.SelectMultiple.Value) { value = string.Join(",", PollUtils.JsonDeserialize <List <string> >(logInfo.Get <string>(fieldInfo.Title))); } else if (fieldInfo.FieldType == InputType.Date.Value) { var date = logInfo.Get <DateTime?>(fieldInfo.Title); if (date.HasValue) { value = date.Value.ToString("yyyy-MM-dd"); } } else if (fieldInfo.FieldType == InputType.DateTime.Value) { var datetime = logInfo.Get <DateTime?>(fieldInfo.Title); if (datetime.HasValue) { value = datetime.Value.ToString("yyyy-MM-dd HH:mm"); } } else { value = logInfo.Get <string>(fieldInfo.Title); } } return(value); }
public IHttpActionResult Get() { try { var request = Context.AuthenticatedRequest; var pollInfo = PollManager.GetPollInfo(request); if (pollInfo == null) { return(NotFound()); } if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId)) { return(Unauthorized()); } var logId = request.GetQueryInt("logId"); var fieldInfoList = FieldManager.GetFieldInfoList(pollInfo.Id); if (logId > 0) { var logInfo = LogManager.Repository.GetLogInfo(logId); foreach (var fieldInfo in fieldInfoList) { if (fieldInfo.FieldType == InputType.CheckBox.Value || fieldInfo.FieldType == InputType.SelectMultiple.Value) { fieldInfo.Value = PollUtils.JsonDeserialize <List <string> >(logInfo.Get <string>(fieldInfo.Title)); } else if (fieldInfo.FieldType == InputType.Date.Value || fieldInfo.FieldType == InputType.DateTime.Value) { fieldInfo.Value = logInfo.Get <DateTime>(fieldInfo.Title); } else { fieldInfo.Value = logInfo.Get <string>(fieldInfo.Title); } } } return(Ok(new { Value = fieldInfoList })); } catch (Exception ex) { return(InternalServerError(ex)); } }