Beispiel #1
0
        public ActionResult Reports()
        {
            try
            {
                var issueRepo  = new IssueRepo();
                var surveyRepo = new SurveyRepo();
                var issueList  = issueRepo.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             = issueList.Count;

                if (count == 0)
                {
                    TempData["Message2"] = "Rapor oluşturmak için yeterli 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 issue in issueList)
                {
                    totalDays += issue.ClosedDate.Value.DayOfYear - issue.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 / issueList.Count;

                return(View(surveyList));
            }
            catch (Exception ex)
            {
                TempData["Message"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "Reports",
                    ControllerName = "Admin",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
        }
Beispiel #2
0
        public JsonResult GetDailyReport()
        {
            try
            {
                var dailyIssues = issueRepo.GetAll(x => x.CreatedDate.DayOfYear == DateTime.Now.DayOfYear).Count;

                return(Json(new ResponseData()
                {
                    data = dailyIssues,
                    success = true
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new ResponseData()
                {
                    data = 0,
                    message = ex.Message,
                    success = false
                }, JsonRequestBehavior.AllowGet));
            }
        }