コード例 #1
0
        private List <StatisticViewModel> GetStatisticViewModels()
        {
            List <StatisticViewModel> result = new List <StatisticViewModel>();

            LanguagesRepository             languagesRepository             = new LanguagesRepository();
            LanguagesTranslationsRepository languagesTranslationsRepository = new LanguagesTranslationsRepository();
            IEnumerable <Languages>         languages = languagesRepository.GetAll();
            List <int> languagesId = languages.Select(l => l.Id).ToList();
            List <CategoryStatistic> categoryStatistics = FillCategory();

            foreach (var languageId in languagesId)
            {
                IEnumerable <LanguageTranslations> languageTranslationsList = languagesTranslationsRepository.GetAll();
                var    id       = languageId;
                string langName = languageTranslationsList
                                  .First(l => l.LangId == id && l.NativeLangId == _userLanguageId).Translation;
                List <CategoryStatistic> listToCopy = Helper.DeepClone(categoryStatistics);
                result.Add(new StatisticViewModel
                {
                    LanguageName       = langName,
                    CategoryStatistics = listToCopy,
                    LanguageId         = languageId
                });
            }
            StatisticViewModel[] statisticArray = new StatisticViewModel[result.Count];
            for (int j = 0; j < statisticArray.Length; j++)
            {
                statisticArray[j] = FillResults(result[j]);
            }

            return(result);
        }
コード例 #2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var userId         = this.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var organizationId = this.organizationsService.GetId(userId);

            var startDate = await this.statisticsService.GetStartDateAsync(organizationId);

            var endDate = DateTime.UtcNow;

            var benefits = await this.statisticsService.GetTotalBenefitsAsync(organizationId, startDate, endDate);

            var bestCustomer = await this.statisticsService.GetBestCustomersAsync <CustomerViewModel>(organizationId);

            var customerWithMostOrders = await this.statisticsService.GetCustomerByOrdersAsync <CustomerViewModel>(organizationId);

            var mostOrdered = await this.statisticsService.GetMostOrderProductAsync <ProductViewModel>(organizationId);

            var mostBenefitProduct = await this.statisticsService.GetMostBenefitProductAsync <ProductViewModel>(organizationId);

            var organizationName = this.organizationsService.GetName(userId);

            var viewModel = new StatisticViewModel
            {
                TotalBenefits          = benefits,
                BestCustomer           = bestCustomer,
                CustomerWithMostOrders = customerWithMostOrders,
                MostOrderedProduct     = mostOrdered,
                MostBenefitProduct     = mostBenefitProduct,
                OrganizationName       = organizationName,
                OrdersCount            = await this.statisticsService.OrdersCount(organizationId),
            };

            return(View(viewModel));
        }
コード例 #3
0
        public IHttpActionResult Post([FromBody] StatisticViewModel statisticViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                statisticViewModel.CreationDate = DateTime.Now;

                var startDate = statisticViewModel.StartDate;
                statisticViewModel.StartDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, 0, 0, 0);

                var endDate = statisticViewModel.EndDate;
                statisticViewModel.EndDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59);

                _statisticService.Insert(AutoMapperGenerator.Mapper.Map <Statistic>(statisticViewModel));
                return(CreatedAtRoute("DefaultApi", new { id = statisticViewModel.Id }, statisticViewModel));
            }
            catch (Exception exception)
            {
                //ErrorSignal.FromCurrentContext().Raise(exception);
                return(InternalServerError(exception));
            }
        }
コード例 #4
0
         public HomeViewModel(UrlHelper urlHelper,CatalogStatistic catalogStatistic )
         {
            TrainingProvidersStatistic = new StatisticViewModel
            {
               Title = "Providers",
               Count = catalogStatistic.TrainingProviderCount,
               Url = urlHelper.RouteUrl(AppConstants.RouteNames.AllTrainingProviders)
            };

            CategoriesStatistic = new StatisticViewModel
            {
               Title = "Categories",
               Count = catalogStatistic.CategoryCount,
               Url = urlHelper.RouteUrl(AppConstants.RouteNames.AllCategories)
            };

            CoursesStatistic = new StatisticViewModel
            {
               Title = "Courses",
               Count = catalogStatistic.CourseCount,
               Url = urlHelper.RouteUrl(AppConstants.RouteNames.AllCourses)
            };

            AuthorsStatistic = new StatisticViewModel
            {
               Title = "Authors",
               Count = catalogStatistic.AuthorCount,
               Url = urlHelper.RouteUrl(AppConstants.RouteNames.AllAuthors)
            };
         }
コード例 #5
0
        public ActionResult Statistic()
        {
            if (Request.Cookies["Admin_userName"] != null && Request.Cookies["Admin_password"] != null)
            {
                string userName = Request.Cookies["Admin_userName"].Value;
                string password = Request.Cookies["Admin_password"].Value;
                var    admin    = AdminDataHelpers.Instance.FindAdmin(userName, password);
                if (admin != null)
                {
                    if (admin.AccountStatus != EventZoneConstants.LockedUser)
                    {
                        UserHelpers.SetCurrentAdmin(Session, admin);
                    }
                }
            }
            StatisticViewModel model = new StatisticViewModel();

            model.EventCountStatistic   = StatisticDataHelpers.Instance.GetEventCount();
            model.EventCreatedEachMonth = StatisticDataHelpers.Instance.GetEventCreatedEachMonth();
            model.TopTenEvents          = StatisticDataHelpers.Instance.GetTopTenEvent();
            model.TopTenLocations       = StatisticDataHelpers.Instance.GetTopLocation();
            model.TopTenUser            = StatisticDataHelpers.Instance.GetTopTenCreatedUser();
            model.GenderRate            = StatisticDataHelpers.Instance.GenderRate();
            model.GroupbyAge            = StatisticDataHelpers.Instance.GetGroupAgeReport();
            model.ReportByStatus        = StatisticDataHelpers.Instance.GetReportByStatus();
            model.ReportByType          = StatisticDataHelpers.Instance.GetReportByType();
            model.AppealByStatus        = StatisticDataHelpers.Instance.GetAppealByStatus();
            model.EventByStatus         = StatisticDataHelpers.Instance.GetEventByStatus();
            return(View(model));
        }
コード例 #6
0
        private StatisticViewModel GetStatistics()
        {
            var r = new Random();

            StatisticViewModel vm = new StatisticViewModel()
            {
                MyHours = new StatisticDataSet()
                {
                    Label = "My Hours", Data = r.Next(100, 240), Color = "#00ACAC", Icon = "fas fa-clock"
                },
                Stories = new StatisticDataSet()
                {
                    Label = "Stories", Data = r.Next(10, 80), Color = "#2F8EE5", Icon = "fas fa-users"
                },
                Remaining = new StatisticDataSet()
                {
                    Label = "Remaining", Data = r.Next(1, 100), Color = "#6C76AF", Icon = "fas fa-hourglass-half"
                },
                Sprints = new StatisticDataSet()
                {
                    Label = "Sprints", Data = r.Next(1, 20), Color = "#EFA64C", Icon = "fas fa-chart-area"
                },
            };

            return(vm);
        }
コード例 #7
0
        public async Task <IActionResult> RangeStatistic(DateTime startDate, DateTime endDate)
        {
            var userId         = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var organizationId = this.organizationsService.GetId(userId);

            var benefits = await this.statisticsService.GetTotalBenefitsAsync(organizationId, startDate, endDate);

            var bestCustomer = await this.statisticsService.GetBestCustomersAsync <CustomerViewModel>(organizationId);

            var customerWithMostOrders = await this.statisticsService.GetCustomerByOrdersAsync <CustomerViewModel>(organizationId);

            var mostOrdered = await this.statisticsService.GetMostOrderProductAsync <ProductViewModel>(organizationId);

            var mostBenefitProduct = await this.statisticsService.GetMostBenefitProductAsync <ProductViewModel>(organizationId);

            var organizationName = this.organizationsService.GetName(userId);

            var viewModel = new StatisticViewModel
            {
                StartDate              = startDate,
                EndDate                = endDate,
                TotalBenefits          = benefits,
                BestCustomer           = bestCustomer,
                CustomerWithMostOrders = customerWithMostOrders,
                MostOrderedProduct     = mostOrdered,
                MostBenefitProduct     = mostBenefitProduct,
                OrganizationName       = organizationName,
            };

            return(this.View(viewModel));
        }
コード例 #8
0
 public static void UpdateStatistic(this Statistic statistic, StatisticViewModel statisticVm)
 {
     statistic.ID    = statisticVm.ID;
     statistic.Name  = statisticVm.Name;
     statistic.Alias = statisticVm.Alias;
     statistic.StatisticCategoryID = statisticVm.StatisticCategoryID;
     statistic.ToDate              = statisticVm.ToDate;
     statistic.FromDate            = statisticVm.FromDate;
     statistic.Description         = statisticVm.Description;
     statistic.Content             = statisticVm.Content;
     statistic.HomeFlag            = statisticVm.HomeFlag;
     statistic.HotFlag             = statisticVm.HotFlag;
     statistic.ViewCount           = statisticVm.ViewCount;
     statistic.Tags                = statisticVm.Tags;
     statistic.Place               = statisticVm.Place;
     statistic.TheInjured          = statisticVm.TheInjured;
     statistic.TheDead             = statisticVm.TheDead;
     statistic.PropertyDamage      = statisticVm.PropertyDamage;
     statistic.SettleBodyID        = statisticVm.SettleBodyID;
     statistic.ResolvedSituationID = statisticVm.ResolvedSituationID;
     statistic.CreatedDate         = statisticVm.CreatedDate;
     statistic.CreatedBy           = statisticVm.CreatedBy;
     statistic.UpdatedBy           = statisticVm.UpdatedBy;
     statistic.UpdatedDate         = statisticVm.UpdatedDate;
     statistic.MetaKeyword         = statisticVm.MetaKeyword;
     statistic.MetaDescription     = statisticVm.MetaDescription;
     statistic.Status              = statisticVm.Status;
 }
コード例 #9
0
        public StatisticViewModel Get(int pageIndex)
        {
            List <Item>        items     = new List <Item>();
            List <Statistic>   stat      = new List <Statistic>();
            StatisticViewModel statistic = new StatisticViewModel();

            using (ItemContext db = new ItemContext())
            {
                items = db.Items.ToList();
                var g = items.GroupBy(i => i.Type).Distinct();

                foreach (var k in g)
                {
                    stat.Add(new Statistic
                    {
                        Type  = k.Key,
                        Count = k.Count()
                    });
                }

                statistic.Count = stat.Count();
                statistic.items = stat.Skip(3 * (pageIndex - 1)).Take(3).ToList();
            }
            if (statistic != null)
            {
                return(statistic);
            }
            return(null);
        }
コード例 #10
0
        // GET: Statistic
        public ActionResult Index(string sortOrder, string search)
        {
            StatisticViewModel statisticModel = new StatisticViewModel();

            if (User.Identity.IsAuthenticated || HttpContext.Session["Email"] != null)
            {
                string email = string.Empty;
                if (User.Identity.IsAuthenticated)
                {
                    MembershipUser user = Membership.GetUser();
                    email = user.Email;
                }
                else if (HttpContext.Session["Email"] != null)
                {
                    email = HttpContext.Session["Email"].ToString();
                }

                statisticModel.Results = this.hangamnProvider.GetPersonalStatistics(email);
            }
            else
            {
                statisticModel.Message = "За да видите личната си статистика е нужно да влезете в акаунта си.";
            }

            return(this.View(statisticModel));
        }
コード例 #11
0
        public JsonResult StatisticSubmit(int lotrinh, int kyghi)
        {
            BillDao db     = new BillDao();
            var     result = new StatisticViewModel();

            if (lotrinh == 0 && kyghi == 0)
            {
                result = db.StatisticAll();
            }
            else if (lotrinh != 0 && kyghi == 0)
            {
                result = db.StatisticLT(lotrinh);
            }
            else if (lotrinh == 0 && kyghi != 0)
            {
                result = db.StatisticKG(kyghi);
            }
            else
            {
                result = db.StatisticLTKG(lotrinh, kyghi);
            }
            var data = new { lt_ten = result.lt_ten, k_ten = result.k_ten, soho = result.soho, sonuoc = result.sonuoc, tongtien = result.tongtien };
            var j    = Json(data, JsonRequestBehavior.AllowGet);

            return(j);
        }
コード例 #12
0
            public HomeViewModel(UrlHelper urlHelper, CatalogStatistic catalogStatistic)
            {
                TrainingProvidersStatistic = new StatisticViewModel
                {
                    Title = "Providers",
                    Count = catalogStatistic.TrainingProviderCount,
                    Url   = urlHelper.RouteUrl(AppConstants.RouteNames.AllTrainingProviders)
                };

                CategoriesStatistic = new StatisticViewModel
                {
                    Title = "Categories",
                    Count = catalogStatistic.CategoryCount,
                    Url   = urlHelper.RouteUrl(AppConstants.RouteNames.AllCategories)
                };

                CoursesStatistic = new StatisticViewModel
                {
                    Title = "Courses",
                    Count = catalogStatistic.CourseCount,
                    Url   = urlHelper.RouteUrl(AppConstants.RouteNames.AllCourses)
                };

                AuthorsStatistic = new StatisticViewModel
                {
                    Title = "Authors",
                    Count = catalogStatistic.AuthorCount,
                    Url   = urlHelper.RouteUrl(AppConstants.RouteNames.AllAuthors)
                };
            }
コード例 #13
0
        // GET: Statistics
        public ActionResult Index()
        {
            var userId = User.Identity.GetUserId <int>();
            var user   = UserManager.FindById(User.Identity.GetUserId <int>());
            var users  = from u in db.Users
                         select u;
            List <StatisticViewModel> models = new List <StatisticViewModel>();


            foreach (ApplicationUser u in users)
            {
                if (!UserManager.GetRoles(u.Id).Contains("Admin"))
                {
                    var model = new StatisticViewModel
                    {
                        UserName          = u.UserName,
                        FullName          = u.FullName,
                        UserTotalDistance = db.DistanceCount(u.Id),
                        UserTotalClimb    = db.ClimbCount(u.Id),
                        UserTourCount     = db.TourCount(u.Id),
                    };
                    models.Add(model);
                }
            }

            ViewBag.UserTotalDistance = db.DistanceCount(user.Id);
            ViewBag.UserTotalClimb    = db.ClimbCount(user.Id);
            ViewBag.DistanceTotal     = db.DistanceTotal();
            ViewBag.ClimbTotal        = db.ClimbTotal();
            ViewBag.TourTotal         = db.TourTotal();
            ViewBag.TourCount         = db.TourCount(user.Id);
            ViewBag.Models            = models.OrderByDescending(x => x.UserTotalDistance).Take(12);

            return(View());
        }
コード例 #14
0
        public async Task <StatisticViewModel> ExecuteAsync(DateTime startDate, DateTime endDate)
        {
            startDate = startDate.ChangeTime(0, 0, 0, 0);
            endDate   = endDate.ChangeTime(23, 59, 59, 999);

            DateTime           now            = DateTime.Now;
            DateTime           startTimeToday = now.ChangeTime(0, 0, 0, 0);
            StatisticViewModel result         = new StatisticViewModel(startDate, endDate);

            var numOfNewCustomers = await _getNumOfNewCustomersQuery.ExecuteAsync(startDate, endDate);

            var ordersResult = await _getListOrderQuery.ExecuteAsync(0, 0, null, null, startDate, endDate, null);

            var todayOrdersResult = await _getListOrderQuery.ExecuteAsync(0, 0, null, null, startTimeToday, now, null);

            result.NumOfNewCustomers   = numOfNewCustomers;
            result.NumOfNewOrders      = ordersResult.Items.Count();
            result.NumOfNewInvoices    = ordersResult.Items.Where(n => n.CompletedTime.HasValue).Count();
            result.FeaturedCategories  = GetFeaturedCategories(ordersResult.Items.Where(n => n.CompletedTime.HasValue));
            result.BestSellingProducts = GetBestSellingProducts(ordersResult.Items.Where(n => n.CompletedTime.HasValue));
            result.CurrentOrder        = GetCurrentOrder(todayOrdersResult.Items);
            result.RevenueOverview     = GetRevenueOverview(todayOrdersResult.Items);
            result.LatestOrders        = GetLatestOrders(todayOrdersResult.Items);

            return(result);
        }
コード例 #15
0
        // GET: Statistics/
        public ActionResult Index()
        {
            StatisticViewModel statistic = _staticticRepository.GetStatisticData(User);

            ViewBag.Title = "Статистика";

            return(View(statistic));
        }
コード例 #16
0
        public StatisticPage()
        {
            viewModel = new StatisticViewModel(this);

            this.BindingContext = viewModel;


            InitializeComponent();
        }
コード例 #17
0
        public async Task <StatisticViewModel> GetStatisticAsync()
        {
            var all = await _context.Emergencies.Include(e => e.Events).ToListAsync();

            var tech = all.Find(e => e.EmergencyId == Constants.TechnogenicId);
            var natr = all.Find(e => e.EmergencyId == Constants.NaturalId);
            var socl = all.Find(e => e.EmergencyId == Constants.SocialId);
            var mili = all.Find(e => e.EmergencyId == Constants.MilitaryId);

            int technogenicNumber = tech.Events == null ? 0 : tech.Events.Count;
            int naturalNumber     = natr.Events == null ? 0 : natr.Events.Count;
            int socialNumber      = socl.Events == null ? 0 : socl.Events.Count;
            int militaryNumber    = mili.Events == null ? 0 : mili.Events.Count;


            int deathNumber  = 0;
            int harmedNumber = 0;

            if (tech.Events != null)
            {
                deathNumber  += tech.Events.Select(t => t.Deaths).Sum().Value;
                harmedNumber += tech.Events.Select(t => t.Harmed).Sum().Value;
            }

            if (natr.Events != null)
            {
                deathNumber  += natr.Events.Select(t => t.Deaths).Sum().Value;
                harmedNumber += natr.Events.Select(t => t.Harmed).Sum().Value;
            }

            if (socl.Events != null)
            {
                deathNumber  += socl.Events.Select(t => t.Deaths).Sum().Value;
                harmedNumber += socl.Events.Select(t => t.Harmed).Sum().Value;
            }

            if (mili.Events != null)
            {
                deathNumber  += mili.Events.Select(t => t.Deaths).Sum().Value;
                harmedNumber += mili.Events.Select(t => t.Harmed).Sum().Value;
            }

            var vm = new StatisticViewModel()
            {
                EventsNumber      = all.Select(eme => eme.Events.Count).Sum(),
                TechnogenicNumber = technogenicNumber,
                NaturalNumber     = naturalNumber,
                SocialNumber      = socialNumber,
                MilitaryNumber    = militaryNumber,

                DeathsCount = deathNumber,
                HarmedCount = harmedNumber
            };

            return(vm);
        }
コード例 #18
0
        public IActionResult AdminStatistics()
        {
            StatisticViewModel vm = new StatisticViewModel();

            vm.Genre = SQLDataAccess.GetGenreStatistics();
            vm.Game  = SQLDataAccess.GetGameStatistics();
            vm.Dev   = SQLDataAccess.GetDevStatistics();

            return(View(vm));
        }
コード例 #19
0
        public StatisticViewModel MapStatisticToViewModel(IStatistic statistics)
        {
            var viewModel = new StatisticViewModel();

            viewModel.Mean  = statistics.Mean;
            viewModel.Stdev = statistics.Stdev;
            viewModel.Skew  = statistics.Skew;
            viewModel.Kurt  = statistics.Kurt;
            return(viewModel);
        }
コード例 #20
0
ファイル: StatisticController.cs プロジェクト: pro2s/FoodApp
        // GET: api/Statistic
        public IHttpActionResult Get()
        {
            StatisticViewModel    result = new StatisticViewModel();
            TopStatistic          top_0  = GetTopUsersByorder();
            List <TotalStatistic> totals = GetTotalStatistic();

            result.Totals = totals;
            result.Tops.Add(top_0);
            return(Ok(result));
        }
コード例 #21
0
 public MainWindow()
 {
     InitializeComponent();
     customerViewModel  = new CustomerViewModel();
     productViewModel   = new ProductViewModel();
     contractViewModel  = new ContractViewModel(customerViewModel.Customers);
     logViewModel       = new LogViewModel();
     statisticViewModel = new StatisticViewModel(contractViewModel.ContractManager);
     DataContext        = new { customerViewModel, productViewModel, contractViewModel, statisticViewModel, logViewModel };
 }
コード例 #22
0
        /// <summary>
        /// Get statistic data.
        /// </summary>
        /// <param name="user">Authorized user.</param>
        /// <returns>Statistic view model data.</returns>
        public StatisticViewModel GetStatisticData(IPrincipal user)
        {
            StatisticViewModel statistic = new StatisticViewModel();

            List <ObjectModel> allObjects;
            List <Company>     currentCompanies;

            if (user.IsInRole("admin") || user.IsInRole("user"))
            {
                allObjects       = _db.ObjectModels.Where(x => x.Id != 0 && (x.Id < 56 || x.Id > 62)).ToList();
                currentCompanies = _db.Companies.Where(x => x.Id != 32).ToList();
            }
            else
            {
                allObjects       = _db.ObjectModels.Where(x => x.Id >= 56 && x.Id <= 62).ToList();
                currentCompanies = _db.Companies.Where(x => x.Id == 32).ToList();
            }

            foreach (Company company in currentCompanies)
            {
                List <ObjectModel> dataInvestors = allObjects.Where(x => x.Investor.Id == company.Id).ToList();
                if (dataInvestors.Count != 0)
                {
                    statistic.Investors.Add(new CompanyDataViewModel
                    {
                        Name         = company.Name,
                        ObjectsCount = dataInvestors.Count
                    });
                }

                List <ObjectModel> dataDesigners = allObjects.Where(x => x.Designer.Id == company.Id).ToList();
                if (dataDesigners.Count != 0)
                {
                    statistic.Designers.Add(new CompanyDataViewModel
                    {
                        Name         = company.Name,
                        ObjectsCount = dataDesigners.Count
                    });
                }

                List <ObjectModel> dataContractors = allObjects.Where(x => x.Contractor.Id == company.Id).ToList();
                if (dataContractors.Count != 0)
                {
                    statistic.Contractors.Add(new CompanyDataViewModel
                    {
                        Name         = company.Name,
                        ObjectsCount = dataContractors.Count
                    });
                }
            }

            statistic.ObjectModels.AddRange(allObjects);

            return(statistic);
        }
コード例 #23
0
 public MainWindowViewModel(string userID)
 {
     _bussiness = new MainWindowBussiness(userID);
     Teaching   = new TeachingManagementViewModel(_bussiness.Teaching);
     Calling    = new NameCallingManagementViewModel(_bussiness.Calling);
     Payment    = new PaymentViewModel(_bussiness.Payment);
     Overdue    = new OverdueViewModel(_bussiness.Overdue);
     Statistic  = new StatisticViewModel(_bussiness.Statistic);
     Setting    = new UserSettingViewModel(_bussiness.UserSetting);
     MainFunc   = 0;
 }
コード例 #24
0
        public async Task <IActionResult> Statistic()
        {
            var client   = new HttpClient();
            var response = await client.GetAsync("http://127.0.0.1:5000/api/TextDetails/Statistic");

            var result = new StatisticViewModel
            {
                Result = await response.Content.ReadAsStringAsync()
            };

            return(View(result));
        }
コード例 #25
0
        public IActionResult Statistic(StatisticViewModel mod)
        {
            StatisticViewModel myModel = new StatisticViewModel();

            myModel.date         = mod.date;
            myModel.DSDH         = getList(myModel.date.Year, myModel.date.Month);
            myModel.DTtheoThang  = TinhDoanhThu(myModel.date.Year);
            myModel.SLDatHang    = LaySoLuongDatHang(myModel.date.Year, myModel.date.Month);
            myModel.SLKhachHang  = LaySoLuongKhachHang(myModel.date.Year, myModel.date.Month);
            myModel.SlDoanhThu   = LayDoanhThu(myModel.date.Year, myModel.date.Month);
            myModel.SLDHthanhPho = KhuVucThanhPho(myModel.date.Year, myModel.date.Month);
            myModel.SLDHNoiThanh = KhuVucNgoaiThanh(myModel.date.Year, myModel.date.Month);
            myModel.DSTopSP      = layTop5SanPham(myModel.date.Year, myModel.date.Month);
            return(View(myModel));
        }
コード例 #26
0
        public ActionResult GetQuizResult(MultipleChoiceAnswer _answer)
        {
            if (string.IsNullOrEmpty(_answer.Answer))
            {
                ModelState.AddModelError("", "You need to choose answer");
                ViewBag.Radiobutton = GetRandomRadiobutton();
                return(PartialView("StatisticPartialView", new StatisticViewModel()));
            }

            var sm = new StatisticManager();

            repository.AddAnswer(_answer);
            StatisticViewModel statisticView = sm.GetQuestionStatistic(repository.GetMultipleQuestion(_answer.QuestionId));

            return(PartialView("StatisticPartialView", statisticView));
        }
コード例 #27
0
        public static StatisticViewModel Map(Statistic statistic)
        {
            StatisticViewModel statisticViewModel = new StatisticViewModel()
            {
                MutantCount   = statistic.MutantCount,
                NoMutantCount = statistic.NoMutantCount
            };

            double?ratio = statistic.GetRatio();

            if (ratio.HasValue)
            {
                statisticViewModel.Ratio = Math.Round(ratio.Value, 1);
            }

            return(statisticViewModel);
        }
コード例 #28
0
 public IHttpActionResult Put([FromBody] StatisticViewModel statisticViewModel)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         _statisticService.Update(AutoMapperGenerator.Mapper.Map <Statistic>(statisticViewModel));
         return(Ok());
     }
     catch (Exception exception)
     {
         //ErrorSignal.FromCurrentContext().Raise(exception);
         return(InternalServerError(exception));
     }
 }
コード例 #29
0
        public async Task <IActionResult> Index()
        {
            StatisticViewModel statisticViewModel = new StatisticViewModel();

            statisticViewModel.Items = await _context.Items.Where(i => i.Type != "GOA").Include(i => i.OrderItems).ToListAsync();

            statisticViewModel.Menus = await _context.Menus.Include(i => i.OrderMenus).ToListAsync();

            statisticViewModel.Orders = await _context.Orders
                                        .Where(i => i.IsPaid == true)
                                        .Include(i => i.OrderItems)
                                        .ThenInclude(i => i.Item)
                                        .Include(i => i.OrderMenus)
                                        .ThenInclude(i => i.Menu).ToListAsync();

            return(View(statisticViewModel));
        }
コード例 #30
0
        public static MvcHtmlString CreateMenuQuiz(this HtmlHelper html, StatisticViewModel _statistic)
        {
            TagBuilder div = new TagBuilder("div");

            div.MergeAttribute("class", "statistic");
            div.InnerHtml += "<h3>" + _statistic.Title + "</h3>";

            foreach (var dictionary in _statistic.Data)
            {
                div.InnerHtml += "<span class='answer - text'>Variant<span class='key'> ";
                div.InnerHtml += dictionary.Key;
                div.InnerHtml += " </span> has chosen<span class='key'> ";
                div.InnerHtml += Math.Floor(dictionary.Value * _statistic.PersentPerPoint);
                div.InnerHtml += "%</span></span> <br/>";
            }

            return(MvcHtmlString.Create(div.ToString()));
        }
コード例 #31
0
        public ActionResult SearchSoph1(StatisticViewModel statistic)
        {
            PartialViewResult view = new PartialViewResult();

            try {
                var rs_search = oc.SearchSoph1(Request, statistic);
                if ((bool)rs_search["success"])
                {
                    return((PartialViewResult)oc.SearchSoph1(Request, statistic)["view"]);
                }
                else
                {
                    return(RedirectToAction("ServerError", "Exception", new { error = (string)rs_search["message"] }));
                }
            } catch (Exception e) {
                return(RedirectToAction("ServerError", "Exception", new { error = e.Message }));
            }
        }
コード例 #32
0
        public ActionResult ForumStatistic()
        {
            StatisticViewModel model = new StatisticViewModel()
            {
                Count = this.homeService.GetTopForumPosts().Count(),
                Text = "Forum posts",
                ColorClass = "panel-green",
                IconClass = "fa-comments-o",
                Link = "Forum"
            };

            return this.PartialView("_Statistic", model);
        }
コード例 #33
0
        public ActionResult CourseStatistic()
        {
            StatisticViewModel model = new StatisticViewModel()
            {
                Count = this.coursesService.GetAll().Count(),
                Text = "Courses",
                ColorClass = "panel-yellow",
                IconClass = "fa-bullhorn",
                Link = "Courses"
            };

            return this.PartialView("_Statistic", model);
        }
コード例 #34
0
        public ActionResult TrainerStatistic()
        {
            var trainerRole = this.usersService.GetRoles().FirstOrDefault(r => r.Name == RoleConstants.Trainer);
            StatisticViewModel model = new StatisticViewModel()
            {
                Count = this.usersService
                        .GetAll()
                        .Where(u => u.Roles.Any(r => r.RoleId == trainerRole.Id)).Count(),
                Text = "Trainers",
                ColorClass = "panel-primary",
                IconClass = "fa-child",
                Link = "Trainers",
            };

            return this.PartialView("_Statistic", model);
        }
コード例 #35
0
        public ActionResult SpecialtiesStatistic()
        {
            StatisticViewModel model = new StatisticViewModel()
            {
                Count = this.specialtiesService
                        .GetAll()
                        .Count(),
                Text = "Specialties",
                ColorClass = "panel-red",
                IconClass = "fa-rocket",
                Link = "Specialties"
            };

            return this.PartialView("_Statistic", model);
        }