Beispiel #1
0
        public JsonResult ShowDonutCharts()
        {
            List <DonutChartResponse> listoChartResponses = new List <DonutChartResponse>();

            var dictionary = new List <DonutChartRequest>();

            try
            {
                dictionary.Add(new DonutChartRequest()
                {
                    label = "Open",
                    value = 1
                }
                               );
                dictionary.Add(new DonutChartRequest()
                {
                    label = "Resolved",
                    value = 2
                }
                               );
                dictionary.Add(new DonutChartRequest()
                {
                    label = "InProgress",
                    value = 3
                }
                               );
                dictionary.Add(new DonutChartRequest()
                {
                    label = "OnHold",
                    value = 4
                }
                               );
                dictionary.Add(new DonutChartRequest()
                {
                    label = "RecentlyEdited",
                    value = 5
                }
                               );
                dictionary.Add(new DonutChartRequest()
                {
                    label = "Replied",
                    value = 6
                }
                               );
                dictionary.Add(new DonutChartRequest()
                {
                    label = "Deleted",
                    value = 7
                }
                               );


                var listofdata = _chart.GetListofDonutChartData(Convert.ToInt64(_sessionHandler.UserId));

                for (int i = 0; i < listofdata.Count; i++)
                {
                    var tempstatusid = listofdata[i].StatusId;

                    var getdata = (from a in dictionary
                                   where a.value == tempstatusid
                                   select a.label).FirstOrDefault();

                    if (tempstatusid == 1)
                    {
                        listoChartResponses.Add(new DonutChartResponse()
                        {
                            label = getdata,
                            value = listofdata[i].New
                        });
                    }
                    else if (tempstatusid == 2)
                    {
                        listoChartResponses.Add(new DonutChartResponse()
                        {
                            label = getdata,
                            value = listofdata[i].Resolved
                        });
                    }
                    else if (tempstatusid == 3)
                    {
                        listoChartResponses.Add(new DonutChartResponse()
                        {
                            label = getdata,
                            value = listofdata[i].InProgress
                        });
                    }
                    else if (tempstatusid == 4)
                    {
                        listoChartResponses.Add(new DonutChartResponse()
                        {
                            label = getdata,
                            value = listofdata[i].OnHold
                        });
                    }
                    else if (tempstatusid == 5)
                    {
                        listoChartResponses.Add(new DonutChartResponse()
                        {
                            label = getdata,
                            value = listofdata[i].RecentlyEdited
                        });
                    }
                    else if (tempstatusid == 6)
                    {
                        listoChartResponses.Add(new DonutChartResponse()
                        {
                            label = getdata,
                            value = listofdata[i].Replied
                        });
                    }
                    else if (tempstatusid == 7)
                    {
                        listoChartResponses.Add(new DonutChartResponse()
                        {
                            label = getdata,
                            value = listofdata[i].Deleted
                        });
                    }
                }

                return(Json(listoChartResponses, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                throw;
            }
        }