public StatisticalViewModel GetStastical() { List <CapitalDataViewModel> capitals = capitalService.GetAllCapitals().Where(x => x.Status == "Finished").ToList(); List <UserDataViewModel> users = accountService.GetAllUsersInfo(); StatisticalViewModel statistical = new StatisticalViewModel(); statistical.TotalCapital = capitals.Sum(x => x.Value); statistical.TotalEquity = capitals.Where(x => x.Type == "Equity").Sum(x => x.Value); statistical.TotalWorking = capitals.Where(x => x.Type == "Working").Sum(x => x.Value); statistical.TotalLongTermAsset = capitals.Where(x => x.Asset == "LongTermAsset").Sum(x => x.Value); statistical.TotalShortTermAsset = capitals.Where(x => x.Asset == "ShortTermAsset").Sum(x => x.Value); statistical.CapitalLineChartDataSet = new List <long>(); statistical.CapitalLineChartLabels = new List <string>(); for (int i = 11; i >= 0; i--) { DateTime temp = DateTime.Today.AddMonths(-i); statistical.CapitalLineChartLabels.Add(temp.ToString("MMM")); long tempSum = capitals.Where(capital => capital.CreationDate.Month == temp.Month && capital.CreationDate.Year == temp.Year) .Sum(x => x.Value); statistical.CapitalLineChartDataSet.Add(tempSum); } statistical.TotalUser = users.Count(); statistical.TopUserList = accountService.GetTopUsers(5); return(statistical); }
// GET: Admin/Statistical public ActionResult Index() { ViewBag.Active = "#Statistical"; StatisticalViewModel model = Helper.Statistical(); return(View(model)); }
public ActionResult Statistical(string session) { var statisticals = new StatisticalsViewModel(); if (session.IsNullOrWhiteSpace()) { return(View(statisticals)); } var years = session.Split('-'); if (!years.Any()) { return(View(statisticals)); } try { var sYear = Convert.ToInt32(years[0]); statisticals.SYear = sYear; statisticals.Statisticals = new List <StatisticalViewModel>(); var faculties = _db.Faculties.ToList(); foreach (var faculty in faculties) { var statistical = new StatisticalViewModel(); statistical.Faculty = faculty; var totalCmr = _db.Reports.Where(r => r.Assignment.Start.Year == sYear) .Count(r => r.Assignment.Course.Faculties.Any(f => f.Id == faculty.Id)); var approvedCmr = _db.Reports.Where(r => r.Assignment.Course.Faculties.Any(f => f.Id == faculty.Id)) .Count(r => r.IsApproved); var commentedCmr = _db.Reports.Where(r => r.Assignment.Course.Faculties.Any(f => f.Id == faculty.Id)) .Count(r => r.Comments.Any(c => c.User.FacultyAssignments.Any(fa => fa.Role == "dlt"))); statistical.TotalCmr = totalCmr; statistical.ApprovedCmr = approvedCmr; statistical.CommentedCmr = commentedCmr; if (statistical.TotalCmr > 0) { statistical.ApprovedPercent = Math.Round((double)(statistical.ApprovedCmr * 100) / statistical.TotalCmr, 2); statistical.CommentedPercent = Math.Round((double)(statistical.CommentedCmr * 100) / statistical.TotalCmr, 2); } statisticals.Statisticals.Add(statistical); } return(View(statisticals)); } catch (Exception) { return(View(statisticals)); } }
public IActionResult Index(string option, int?monthSearch, int?yearSearch) { if (monthSearch.HasValue) { if (monthSearch.Value == 0) { monthSearch = DateTime.Now.Month; } } else { monthSearch = DateTime.Now.Month; } if (yearSearch.HasValue) { if (yearSearch.Value == 0) { yearSearch = DateTime.Now.Year; } } else { yearSearch = DateTime.Now.Year; } var model = new StatisticalViewModel(); if (option == null || option == "dayinmonth") { option = "dayinmonth"; //string date = DateTime.Now.ToString("dd/MM/yyyy"); model.option = option; model.monthSearch = monthSearch.Value; model.yearSearch = yearSearch.Value; model.statisticals = _orderRepository.RevenueStatistical(option, monthSearch.Value, yearSearch.Value).AsEnumerable().ToList(); } else { model.option = option; model.monthSearch = 0; model.yearSearch = yearSearch.Value; model.statisticals = _orderRepository.RevenueStatistical(option, monthSearch.Value, yearSearch.Value).AsEnumerable().ToList(); } return(View(model)); }
public StatisticalWindow() { InitializeComponent(); this.DataContext = ViewModel = new StatisticalViewModel(); }
public ActionResult <StatisticalViewModel> GetStatic() { StatisticalViewModel result = statisticalService.GetStastical(); return(Ok(result)); }