Exemple #1
0
        public async Task <ActionResult> CancelStatistic(int id)
        {
            StatisticVM statistic = new StatisticVM(await db.GetStatisticsById(id));

            statistic.Update();
            return(PartialView("Partial/_StatisticRow", statistic));
        }
Exemple #2
0
        public async Task <ActionResult> ResetStatistic(int id)
        {
            await db.UpdateStatisticPerformedResetAsync(id);

            StatisticVM statistic = new StatisticVM(await db.GetStatisticsById(id));

            statistic.Update();
            return(PartialView("Partial/_StatisticRow", statistic));
        }
Exemple #3
0
        public async Task <ActionResult> SaveStatistic(Statistic model)
        {
            await db.UpdateUserCourseFileAsync(model, model.FileId == 0?true : false);

            StatisticVM statistic = new StatisticVM(await db.GetStatisticsById(model.StatisticId));

            statistic.Update();
            return(PartialView("Partial/_StatisticRow", statistic));
        }
Exemple #4
0
        public async Task <ActionResult> ExportData(int CourseId, int CourseTopicFileId)
        {
            bool IsTeacher = await db.IsTeacherByEmailAsync(User.Identity.Name);

            if (!IsTeacher)
            {
                return(RedirectToAction("Error"));
            }
            bool IsAccess = await db.HaveTeacherAccessToCourseByEmailAsync(User.Identity.Name, CourseId);

            if (!IsAccess)
            {
                return(RedirectToAction("Error"));
            }

            ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.Commercial;
            using (ExcelPackage package = new ExcelPackage())
            {
                ExcelWorksheet ws = package.Workbook.Worksheets.Add("Statistics");

                List <StatisticVM> statistics = (await db.GetStatisticsByCourseTopicFileId(CourseTopicFileId)).Select(x => new StatisticVM(x)).ToList();
                foreach (StatisticVM item in statistics)
                {
                    item.Update();
                }

                int rows = statistics.Count + 1;
                ws.Cells["A1"].LoadFromDataTable(ToDataTable(statistics), true);
                ws.Cells[$"A1:F{rows}"].AutoFitColumns();
                ws.Cells[$"A1:F{rows}"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;

                ws.Cells["A1:F1"].Style.Fill.PatternType = ExcelFillStyle.Solid;
                ws.Cells["A1:F1"].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(217, 225, 242));
                ws.Cells["A1:F1"].Style.Font.Bold = true;
                ws.Cells[$"A1:F{rows}"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                ws.Cells[$"A1:F{rows}"].Style.Border.Top.Style    = ExcelBorderStyle.Thin;
                ws.Cells[$"A1:F{rows}"].Style.Border.Left.Style   = ExcelBorderStyle.Thin;
                ws.Cells[$"A1:F{rows}"].Style.Border.Right.Style  = ExcelBorderStyle.Thin;
                ws.Cells[$"A1:F{rows}"].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;

                MemoryStream stream = new MemoryStream();
                package.SaveAs(stream);

                string      fileName  = "Статистика";
                StatisticVM statistic = statistics.FirstOrDefault();
                if (statistic != null)
                {
                    fileName = $"{statistic.Course.Name} ({statistic.CourseTopic.SectionName} - {(statistic.CourseTopicFile.IsVariant ? statistic.CourseTopicFile.Name : statistic.File.Name)}) - Статистика.xlsx";
                }

                string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

                stream.Position = 0;
                return(File(stream, contentType, fileName));
            }
        }
Exemple #5
0
        public async Task <ActionResult> EditStatistic(int id)
        {
            StatisticVM statistic = new StatisticVM(await db.GetStatisticsById(id));

            statistic.Update();
            List <Models.File> files = new List <Models.File>();

            foreach (CourseTopicFileTask courseTopicFileTask in await db.GetCourseTopicFileTasksByCourseTopicFileId(statistic.CourseTopicFileId))
            {
                files.Add(await db.GetFileByIdAsync(courseTopicFileTask.FileId));
            }
            ViewBag.Files = files;
            return(PartialView("Partial/Edit/_EditStatisticRow", statistic));
        }
        private void OnStartUp(object sender, StartupEventArgs e)
        {
            ///<remarks>Подсоединение обработчика закрытия окна</remarks>
            window.Closed += Window_Closed;

            ///<remarks>Заполнение словаря соответствий</remarks>
            controls.Add(typeof(IFirstScreenVM), firstScreenUC);
            controls.Add(typeof(IStatisticVM), statisticUC);
            controls.Add(typeof(ISettingsVM), settingsUC);
            controls.Add(typeof(IStatusesVM), gameUC);

            //controls.Add(typeof(IGameEndVM), gameEndUC);
            //controls.Add(typeof(IGameEndDrawVM), drawUC);


            ChangeWindowContent(typeof(IFirstScreenVM));

            IReposSaveGame  reposGame      = new ReposSaveGameXML("SavedGame.xml");
            IReposStatistic reposStatistic = new RepoStatistic("Statistic.xml");

            //Model.ModelTicTacToe.FileNameXml = ;
            model = new ModelTicTacToe(reposGame, reposStatistic);
            //MainViewModel viewModel = new MainViewModel(ChangeWindowContent);
            StatisticVM statisticVM = new StatisticVM(ChangeWindowContent, reposStatistic);
            MainVM      viewModel   = new MainVM(ChangeWindowContent, model, 3, 3, 3, statisticVM);

            viewModel.CellTypes.Add(CellTypeDto.Empty);
            viewModel.CellTypes.Add(CellTypeDto.Cross);
            viewModel.CellTypes.Add(CellTypeDto.Zero);
            viewModel.FirstGamer.CellType  = viewModel.CellTypes[1];
            viewModel.SecondGamer.CellType = viewModel.CellTypes[2];
            ImageSource[] images =
            {
                (ImageSource)imageSourceConverter.ConvertFrom(new Uri("pack://application:,,,/View;component/Resources/Images/cross.png")),
                (ImageSource)imageSourceConverter.ConvertFrom(new Uri("pack://application:,,,/View;component/Resources/Images/zero.png")),
                (ImageSource)imageSourceConverter.ConvertFrom(new Uri("pack://application:,,,/View;component/Resources/Images/yes.png")),
                (ImageSource)imageSourceConverter.ConvertFrom(new Uri("pack://application:,,,/View;component/Resources/Images/no.png"))
            };

            viewModel.FirstGamer.Image       = images[0];
            viewModel.SecondGamer.Image      = images[1];
            viewModel.FirstGamer.ImageIndex  = 0;
            viewModel.SecondGamer.ImageIndex = 1;
            viewModel.PiecesCollection       = images;
            //viewModel.IsRevenge = File.Exists(Model.FileNameXml);

            window.DataContext = viewModel;
            window.Show();
        }
 public StatisticView(IEventAggregator eventAggregator, IMyMessageDialog myMessageDialog)
 {
     InitializeComponent();
     _viewModel  = new StatisticVM(eventAggregator, myMessageDialog);
     DataContext = _viewModel;
 }