Пример #1
0
        public ActionResult Reports()
        {
            try
            {
                var failureRepo       = new FailureRepo();
                var surveyRepo        = new SurveyRepo();
                var failureList       = failureRepo.GetAll(x => x.SurveyId != null).ToList();
                var surveyList        = surveyRepo.GetAll().Where(x => x.IsDone).ToList();
                var totalSpeed        = 0.0;
                var totalTech         = 0.0;
                var totalPrice        = 0.0;
                var totalSatisfaction = 0.0;
                var totalSolving      = 0.0;
                var count             = failureList.Count;

                if (count == 0)
                {
                    TempData["Message"] = "Herhangi bir kayıt bulunamadı.";
                    return(RedirectToAction("Index", "Home"));
                }
                foreach (var survey in surveyList)
                {
                    totalSpeed        += survey.Speed;
                    totalTech         += survey.TechPoint;
                    totalPrice        += survey.Pricing;
                    totalSatisfaction += survey.Satisfaction;
                    totalSolving      += survey.Solving;
                }
                var totalDays = 0;

                foreach (var failure in failureList)
                {
                    if (failure.FinishingTime.HasValue)
                    {
                        totalDays += failure.FinishingTime.Value.DayOfYear - failure.CreatedDate.DayOfYear;
                    }
                }

                ViewBag.AvgSpeed        = totalSpeed / count;
                ViewBag.AvgTech         = totalTech / count;
                ViewBag.AvgPrice        = totalPrice / count;
                ViewBag.AvgSatisfaction = totalSatisfaction / count;
                ViewBag.AvgSolving      = totalSolving / count;
                ViewBag.AvgTime         = totalDays / failureList.Count;

                return(View(surveyList));
            }
            catch (Exception ex)
            {
                TempData["Message"] = new ErrorViewModel()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "Reports",
                    ControllerName = "Admin",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error", "Home"));
            }
        }
Пример #2
0
        public JsonResult GetSurveyReport()
        {
            try
            {
                var surveys = new SurveyRepo();
                var count   = surveys.GetAll().Count;
                var quest1  = surveys.GetAll().Select(x => x.Satisfaction).Sum() / count;
                var quest2  = surveys.GetAll().Select(x => x.TechPoint).Sum() / count;
                var quest3  = surveys.GetAll().Select(x => x.Speed).Sum() / count;
                var quest4  = surveys.GetAll().Select(x => x.Pricing).Sum() / count;
                var quest5  = surveys.GetAll().Select(x => x.Solving).Sum() / count;

                var data = new List <SurveyReport>();
                data.Add(new SurveyReport()
                {
                    question = "Genel Memnuniyet",
                    point    = quest1
                });
                data.Add(new SurveyReport()
                {
                    question = "Teknisyen",
                    point    = quest2
                });
                data.Add(new SurveyReport()
                {
                    question = "Hız",
                    point    = quest3
                });
                data.Add(new SurveyReport()
                {
                    question = "Fiyat",
                    point    = quest4
                });
                data.Add(new SurveyReport()
                {
                    question = "Çözüm Odaklılık",
                    point    = quest5
                });

                return(Json(new ResponseData()
                {
                    message = $"{data.Count} adet kayıt bulundu",
                    success = true,
                    data = data
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new ResponseData()
                {
                    message = "Kayıt bulunamadı" + ex.Message,
                    success = false
                }, JsonRequestBehavior.AllowGet));
            }
        }