public JsonResult GetManagementDashboardLostOpp(string type) { List <int> dataList = new List <int>(); List <double> percentageList = new List <double>(); try { ManagementDashboardLostOpp objLostOpp = new ManagementDashboardLostOpp(); objLostOpp = MDR.GetManagementDashboardLostOpp(type); var total = objLostOpp.LessThanTwo + objLostOpp.TwoToThree + objLostOpp.MoreThanThree; double LessThanTwo = (double)objLostOpp.LessThanTwo * 100 / total; double TwoToThree = (double)objLostOpp.TwoToThree * 100 / total; double MoreThanThree = (double)objLostOpp.MoreThanThree * 100 / total; LessThanTwo = Math.Round(LessThanTwo, 2); TwoToThree = Math.Round(TwoToThree, 2); MoreThanThree = Math.Round(MoreThanThree, 2); percentageList.Add(LessThanTwo); percentageList.Add(TwoToThree); percentageList.Add(MoreThanThree); var lstData = string.Join(" ", dataList); } catch (Exception ex) { newexception.AddException(ex); } return(new JsonResult() { Data = percentageList, JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue }); }
public ManagementDashboardLostOpp GetManagementDashboardLostOpp(string type) { ManagementDashboardLostOpp objLostOpp = new ManagementDashboardLostOpp(); using (var context = new ChitaleDBContext()) { try { objLostOpp = context.Database.SqlQuery <ManagementDashboardLostOpp>("sp_GetAvgOrderToRavanaDate @pi_CustomerType", new SqlParameter("@pi_CustomerType", type)).FirstOrDefault <ManagementDashboardLostOpp>(); } catch (Exception ex) { } } return(objLostOpp); }