public static Source_Json Convert_Json_To_Source_Json(string json_source) { try { Source_Json source = new Source_Json(); source = JsonConvert.DeserializeObject <Source_Json>(json_source); return(source); } catch (Exception ex) { Helper.WriteToFile(string.Format("Invalid Json. please check the provided Json {0}, Detail Error:- {1}", json_source, ex)); return(null); } }
//public static IList<MetricDTO> Convert_List_Table_To_List_DTO(IEnumerable<tblMetric> tbl_Metrics) //{ // IList<MetricDTO> list_metric_dto = new List<MetricDTO>(); // foreach(tblMetric tbl_Metric in tbl_Metrics) // { // //list_metric_dto.Add(Convert_Table_To_DTO(tbl_Metric)); // } // return list_metric_dto; //} /// <summary> /// /// </summary> /// <param name="tbl_Metric"></param> /// <returns></returns> private static MetricDTO Convert_Table_To_DTO(tblMetric tbl_Metric, IList <TagDTO> tag_dto, IList <ElementDTO> element_dto) { MetricDTO dto_metric = new MetricDTO(); try { dto_metric.Id = tbl_Metric.Id; dto_metric.Metric_Name = tbl_Metric.Metric_Name; dto_metric.Metric_Type = MetricType.User.ToString(); dto_metric.Source = Source_Json.Convert_Json_To_Source_Json(tbl_Metric.Source); dto_metric.Tags = tag_dto; dto_metric.Elements = element_dto; dto_metric.Rollup_Function = (Rollup_Function_Option)Enums.TryParse(typeof(Rollup_Function_Option), tbl_Metric.Rollup_Function.ToString()); dto_metric.Unit = Unit_Of_Measurement_DTO_Convert.Convert_Table_To_DTO(tbl_Metric.tblUnit); dto_metric.Unit_Id = tbl_Metric.Unit_Id; } catch { } return(dto_metric); }