Ejemplo n.º 1
0
        private string MediaChartAsync()
        {
            var fileType = dbc.MFiletype.ToListAsync().Result;
            var fileInfo = dbc.TFileinfo.ToListAsync().Result;

            //var fileTypeList = await fileType;
            //var fileInfoList = await fileInfo;

            ChartView cv = new ChartView();


            PropertyInfo[] pi = cv.GetType().GetProperties();


            foreach (PropertyInfo p in pi)
            {
                if (fileType.Any(a => a.TypeName == "." + p.Name))
                {
                    string typeId = fileType.Where(w => w.TypeName == "." + p.Name).First().TypeId;
                    int    value  = fileInfo.Count(c => c.TypeId == typeId);
                    p.SetValue(cv, value);
                }
            }

            cv.total = fileInfo.Count;

            return(JsonConvert.SerializeObject(cv));
        }