public bool Add(StatisticModel item) { bool added; if (item != null) { Statistic statistic = new Statistic() { StatisticID = item.StatisticID, UserID = item.UserID, TestID = item.TestID, CorrectAnswer = item.CorrectAnswer, Passed = item.Passed, QuestionsTotal = item.QuestionsTotal }; _statisticRepository.Add(statistic); added = true; } else { added = false; } return(added); }
public void TestStatistic() { CategoryModel categoryModel = new CategoryModel(); // TODO: 初始化為適當值 Category categoryMovie = new Category(CATEGORY_NAME_MOVIE); Category categoryWork = new Category(CATEGORY_NAME_WORK); categoryModel.AddCategory(categoryMovie); categoryModel.AddCategory(categoryWork); RecordModel recordModel = new RecordModel(categoryModel); // TODO: 初始化為適當值 DateTime now = DateTime.Now; DateTime date = new DateTime(now.Year, now.Month, now.Day); Record workRecord = new Record(date, categoryWork, 1000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 2000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 3000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 4000); recordModel.AddRecord(workRecord); StatisticModel statisticModel = new StatisticModel(categoryModel, recordModel); // TODO: 初始化為適當值 Statistic statistic = statisticModel.GetStatistic(categoryWork, true); Assert.AreEqual(10000, statistic.Amounts); Assert.AreEqual(categoryWork, statistic.Category); Assert.AreEqual(4, statistic.Count); }
public void TestGetBalance() { CategoryModel categoryModel = new CategoryModel(); // TODO: 初始化為適當值 Category categoryMovie = new Category(CATEGORY_NAME_MOVIE); Category categoryWork = new Category(CATEGORY_NAME_WORK); categoryModel.AddCategory(categoryMovie); categoryModel.AddCategory(categoryWork); RecordModel recordModel = new RecordModel(categoryModel); // TODO: 初始化為適當值 DateTime now = DateTime.Now; DateTime date = new DateTime(now.Year, now.Month, now.Day); Record movieRecord = new Record(date, categoryMovie, -1000); recordModel.AddRecord(movieRecord); movieRecord = new Record(date, categoryMovie, -2000); recordModel.AddRecord(movieRecord); movieRecord = new Record(date, categoryMovie, -3000); recordModel.AddRecord(movieRecord); Record workRecord = new Record(date, categoryWork, 1000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 2000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 3000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 4000); recordModel.AddRecord(workRecord); StatisticModel statisticModel = new StatisticModel(categoryModel, recordModel); // TODO: 初始化為適當值 int balance = statisticModel.GetBalance(recordModel.Records); Assert.AreEqual(4000, balance); }
public void TestGetExpenseStatistics() { CategoryModel categoryModel = new CategoryModel(); // TODO: 初始化為適當值 Category categoryMovie = new Category(CATEGORY_NAME_MOVIE); Category categoryWork = new Category(CATEGORY_NAME_WORK); categoryModel.AddCategory(categoryMovie); categoryModel.AddCategory(categoryWork); RecordModel recordModel = new RecordModel(categoryModel); // TODO: 初始化為適當值 DateTime now = DateTime.Now; DateTime date = new DateTime(now.Year, now.Month, now.Day); Record movieRecord = new Record(date, categoryMovie, 1000); recordModel.AddRecord(movieRecord); movieRecord = new Record(date, categoryMovie, 1000); recordModel.AddRecord(movieRecord); movieRecord = new Record(date, categoryMovie, -1000); recordModel.AddRecord(movieRecord); Record workRecord = new Record(date, categoryWork, 1000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 2000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 3000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 4000); recordModel.AddRecord(workRecord); StatisticModel statisticModel = new StatisticModel(categoryModel, recordModel); // TODO: 初始化為適當值 BindingList <Statistic> statistics; statistics = statisticModel.GetExpenseStatistics(); Assert.AreEqual(1, statistics.Count); }
public void TestSetPercent() { const String SEVENTY_FIVE_PERCENT = "75%"; const String TWENTY_FIVE_PERCENT = "25%"; CategoryModel categoryModel = new CategoryModel(); // TODO: 初始化為適當值 Category categoryMovie = new Category(CATEGORY_NAME_MOVIE); Category categoryEntertainment = new Category(CATEGORY_NAME_ENTERTAINMENT); categoryModel.AddCategory(categoryMovie); categoryModel.AddCategory(categoryEntertainment); RecordModel recordModel = new RecordModel(categoryModel); // TODO: 初始化為適當值 StatisticModel statisticModel = new StatisticModel(categoryModel, recordModel); // TODO: 初始化為適當值 BindingList <Statistic> statistics = new BindingList <Statistic>(); // TODO: 初始化為適當值 Statistic statisticMovie = new Statistic(categoryMovie); Statistic statisticEntertainment = new Statistic(categoryEntertainment); statisticMovie.Amounts = 1000; statistics.Add(statisticMovie); statisticEntertainment.Amounts = 3000; statistics.Add(statisticEntertainment); int amounts = 4000; // TODO: 初始化為適當值 statisticModel.SetPercent(statistics, amounts); Assert.AreEqual(TWENTY_FIVE_PERCENT, statisticMovie.Percent); Assert.AreEqual(SEVENTY_FIVE_PERCENT, statisticEntertainment.Percent); }
public void TestGetAmounts() { CategoryModel categoryModel = new CategoryModel(); // TODO: 初始化為適當值 Category categoryMovie = new Category(CATEGORY_NAME_MOVIE); Category categoryWork = new Category(CATEGORY_NAME_WORK); categoryModel.AddCategory(categoryMovie); categoryModel.AddCategory(categoryWork); RecordModel recordModel = new RecordModel(categoryModel); // TODO: 初始化為適當值 DateTime now = DateTime.Now; DateTime date = new DateTime(now.Year, now.Month, now.Day); Record movieRecord = new Record(date, categoryMovie, -1000); recordModel.AddRecord(movieRecord); movieRecord = new Record(date, categoryMovie, -2000); recordModel.AddRecord(movieRecord); movieRecord = new Record(date, categoryMovie, -3000); recordModel.AddRecord(movieRecord); Record workRecord = new Record(date, categoryWork, 1000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 2000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 3000); recordModel.AddRecord(workRecord); workRecord = new Record(date, categoryWork, 4000); recordModel.AddRecord(workRecord); StatisticModel statisticModel = new StatisticModel(categoryModel, recordModel); // TODO: 初始化為適當值 int income = statisticModel.GetAmounts(recordModel.Records, true); Assert.AreEqual(10000, income); int expense = statisticModel.GetAmounts(recordModel.Records, false); Assert.AreEqual(-6000, expense); }
public bool Update(StatisticModel item) { bool updated; if (item != null || item.StatisticID < 0) { Statistic statistic = new Statistic() { StatisticID = item.StatisticID, UserID = item.UserID, TestID = item.TestID, CorrectAnswer = item.CorrectAnswer, Passed = item.Passed, QuestionsTotal = item.QuestionsTotal }; _statisticRepository.Update(statistic); updated = true; } else { updated = false; } return(updated); }
public static List <ViewKQ> show_New_Result() { StatisticModel model = new StatisticModel(); List <ViewKQ> newList = new List <ViewKQ>(); initFlag(model); //string[] text = new string[2]; var list = model.ListAll(); int number = compare(list); if (number == 0) { return(null); } else { var i = number; for (i = number; i >= 1; i--) { int index = list.Count - i; newList.Add(list[index]); } return(newList); } }
public async Task <IActionResult> TestPassed(int totalMarks) { List <CorrectAnswerEditModel> rememberPreviousQuestionResult = _httpContextAccessor.HttpContext.Session.Get <List <CorrectAnswerEditModel> >("ListOfQuestionsResult"); _httpContextAccessor.HttpContext.Session.Remove("ListOfQuestionsResult"); var testId = rememberPreviousQuestionResult[0].TestId; var test = _serviceManager.Tests.GetTestById(testId); AppUser user = await _userManager.FindByEmailAsync(User.Identity.Name); StatisticModel statModel = new StatisticModel() { Test = test, User = user, Result = totalMarks }; _serviceManager.Statistics.SetIntoDb(statModel); _serviceManager.UserTestAccess.RemoveAccessByUserIdAndTestId(user.Id, testId); ViewBag.TotalMarks = totalMarks; ViewBag.TestId = testId; //not used ViewBag.TestTitle = test.Name; var models = _serviceManager.CorrectAnswers.GetModelsFromEditToView(rememberPreviousQuestionResult); return(View(models)); }
public TemplateService(string latexContent, StatisticModel statisticModel, MetaDataModel metaDataModel, string templateName) { _latexContent = latexContent; _statisticModel = statisticModel; _metaDataModel = metaDataModel; _templateName = templateName; }
public ActionResult <int> Add([FromForm] StatisticModel value) { _db.Records.Add(value); _db.SaveChanges(); return(value.Id); }
public async Task <StatisticModel> GetStatisticAsync(SearchTransactionHistory searchTransactionHistory = null) { var result = new StatisticModel(); var predicate = SetPredicate(searchTransactionHistory); var listTransactionHistoryAccountFee = (await _unitOfWork.TransactionHistoryRepository.GetAllAsync("User")).Where(i => i.TransactionType == TransactionType.AccountFee)?.Where(predicate)?.ToList(); if (listTransactionHistoryAccountFee != null) { result.TotalAccountFee = listTransactionHistoryAccountFee.Sum(i => i.Amount); } var listTransactionHistoryWithdrawalFee = (await _unitOfWork.TransactionHistoryRepository.GetAllAsync("User")).Where(i => i.TransactionType == TransactionType.WithdrawalFee)?.Where(predicate)?.ToList(); if (listTransactionHistoryAccountFee != null) { result.TotalWithdrawalFee = listTransactionHistoryWithdrawalFee.Sum(i => i.Amount); } var listTransactionHistoryQuickWithdrawal = (await _unitOfWork.TransactionHistoryRepository.GetAllAsync("User")).Where(i => i.TransactionType == TransactionType.Withdrawal && i.WithdrawalType != null && i.WithdrawalType == WithdrawalType.Quick)?.Where(predicate)?.ToList(); if (listTransactionHistoryAccountFee != null) { result.TotalQuickWithdrawal = listTransactionHistoryQuickWithdrawal.Sum(i => i.Amount); } return(result); }
void OnSetChanged(LeasingSet set) { if (set == null) { return; } switch (set.Monthes.Count) { case 0: break; case 1: FromMonth = set.Monthes[0].Month; ToMonth = set.Monthes[0].Month; break; default: FromMonth = set.Monthes[0].Month; ToMonth = set.Monthes[set.Monthes.Count - 1].Month; break; } if (m_Window != null) { m_Window.LeasingChart.LeasingSet = set; } Statistic = new StatisticModel(); Statistic.Load(set); }
public ActionResult Statistics() { if (User.Identity.IsAuthenticated && @Roles.Provider.IsUserInRole(User.Identity.Name, "Admin")) { StatisticModel statistic = new StatisticModel(); var orders = _orderLogic.GetOrders(); decimal allIncome = 0; int allQuantity = 0; foreach (var item in orders) { allIncome += (decimal)item.OrderPrice; allQuantity += (int)item.OrderQuantity; } var ordersmounth = _orderLogic.GetOrders().Where(u => u.OrderDate.Value.Month >= DateTime.Now.Month); decimal mounthIncome = 0; int mounthQuantity = 0; foreach (var item in orders) { mounthIncome += (decimal)item.OrderPrice; mounthQuantity += (int)item.OrderQuantity; } statistic.AllIncome = allIncome; statistic.AllCount = allQuantity; statistic.Monthlyincome = mounthIncome; statistic.MonthlyCount = mounthQuantity; return(View(statistic)); } else { return(HttpNotFound()); } }
public void TestGetStatisticModel() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 StatisticModel statisticModel = ezMoneyModel.StatisticModel; Assert.AreEqual(statisticModel, ezMoneyModel.StatisticModel); }
/// <summary> /// The data in statistic view should be changed when this is ran. All the data is retrieved from StatisticModel sm /// </summary> /// <param name="sm"></param> The statistic model that is going to be used. /// <param name="res"></param>This will either be 1 or 2. When its 1 it should change the data for label 1 and if its 2 it should change label 2 public void SetData(StatisticModel sm, int res) { if (res == 1) { gemiddeldeLabel1.Text = sm.Gemiddelde.ToString().Equals("-1") ? "n.v.t." : sm.Gemiddelde.ToString(); standaardafwijkingLabel1.Text = sm.Standaardafwijking.ToString().Equals("-1") ? "n.v.t." : sm.Standaardafwijking.ToString(); kleinsteWaardeLabel1.Text = sm.KleinsteWaarde.ToString().Equals("-1") ? "n.v.t." : sm.KleinsteWaarde.ToString(); eersteKwartielLabel1.Text = sm.EersteKwartiel.ToString().Equals("-1") ? "n.v.t." : sm.EersteKwartiel.ToString(); mediaanLabel1.Text = sm.Mediaan.ToString().Equals("-1") ? "n.v.t." : sm.Mediaan.ToString(); derdeKwartielLabel1.Text = sm.DerdeKwartiel.ToString().Equals("-1") ? "n.v.t." : sm.DerdeKwartiel.ToString(); grootsteWaardeLabel1.Text = sm.GrootsteWaarde.ToString().Equals("-1") ? "n.v.t." : sm.GrootsteWaarde.ToString(); } if (res == 2) { gemiddeldeLabel2.Text = sm.Gemiddelde.ToString().Equals("-1") ? "n.v.t." : sm.Gemiddelde.ToString(); standaardafwijkingLabel2.Text = sm.Standaardafwijking.ToString().Equals("-1") ? "n.v.t." : sm.Standaardafwijking.ToString(); kleinsteWaardeLabel2.Text = sm.KleinsteWaarde.ToString().Equals("-1") ? "n.v.t." : sm.KleinsteWaarde.ToString(); eersteKwartielLabel2.Text = sm.EersteKwartiel.ToString().Equals("-1") ? "n.v.t." : sm.EersteKwartiel.ToString(); mediaanLabel2.Text = sm.Mediaan.ToString().Equals("-1") ? "n.v.t." : sm.Mediaan.ToString(); derdeKwartielLabel2.Text = sm.DerdeKwartiel.ToString().Equals("-1") ? "n.v.t." : sm.DerdeKwartiel.ToString(); grootsteWaardeLabel2.Text = sm.GrootsteWaarde.ToString().Equals("-1") ? "n.v.t." : sm.GrootsteWaarde.ToString(); } mainController.mainView.tabPanels.SelectedIndex = 2; }
public List <StatisticModel> GetAllByTestId(int testId) { var statistics = _dataManager.Statistics.GetAllById(testId); List <StatisticModel> models = new List <StatisticModel>(); if (statistics.Count != 0) { var test = _dataManager.Tests.GetTestById(testId); UserViewModel userVM = new UserViewModel(); userVM.Id = statistics.First().User.Id; userVM.FirstName = statistics.First().User.FirstName; userVM.LastName = statistics.First().User.LastName; TestViewModel testVM = new TestViewModel(); testVM.Id = test.Id; testVM.Name = test.Name; testVM.PassToDate = test.PassToDate; testVM.User = userVM; testVM.Created = test.Created; foreach (var stat in statistics) { StatisticModel model = new StatisticModel(); model.User = stat.User; model.Test = testVM; model.Result = stat.Result; model.Id = stat.Id; model.PassTo = stat.Test.PassToDate; model.PassedDate = stat.PassedDate; models.Add(model); } } return(models); }
public StatisticProductProfitReportWindow(List <RecordProfitProducts> records, StatisticModel Model) { this.Model = Model; InitializeComponent(); this.Text = Model.Title; Assembly asm = Assembly.LoadFrom(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Res.dll")); this.Icon = new Icon(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Statistic.ico")); Model.DataSource = records; ProductProfitReport report = new ProductProfitReport(Model.Parameters["PriceSymbol"].ToString()); webBrowser1.Refresh(); string htmlContent = report.ProcessHTMLContent(Model); webBrowser1.DocumentText = htmlContent; }
/// <summary> /// Successfunction that is called after the combinedInfoRequest was successfull /// </summary> /// <param name="result"></param> public void CombinedInfoSuccess(GetPlayerCombinedInfoResult result) { CurrentPlayer = result.InfoResultPayload.PlayerProfile; CurrentPlayerAccount = result.InfoResultPayload.AccountInfo; if (result.InfoResultPayload.UserVirtualCurrency.TryGetValue("CR", out int balance)) { GameInstance.instance.credits = balance; Credits = balance.ToString(); } else { GameInstance.instance.credits = 0; Credits = "0"; } var statisticList = new List <StatisticModel>(); foreach (var statisticValue in result.InfoResultPayload.PlayerStatistics) { var model = new StatisticModel { Value = statisticValue.Value, Name = statisticValue.StatisticName }; statisticList.Add(model); } CurrentPlayer.Statistics = statisticList; fullyLoaded = true; }
private async void SendStatistic() { await Task.Run(async() => { try { var statistic = new StatisticModel { Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(), Type = StatisticType.Installation }; var serializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = new List <JsonConverter> { new StringEnumConverter() } }; var json = JsonConvert.SerializeObject(statistic, serializerSettings); var content = new StringContent(json, Encoding.UTF8, "application/json"); using (var httpClient = new HttpClient()) { await httpClient.PostAsync("https://yakd.000webhostapp.com/api/statistic/create.php", content); } Properties.Settings.Default.FirstLaunchStatistic = true; } catch (Exception) { Properties.Settings.Default.FirstLaunchStatistic = false; } }); }
public StatisticViewModel( StatisticService statistic, ConfigService config, TomatoService tomato) { this.statistic = statistic; this.config = config; this.tomato = tomato; yearmonth = DateTime.Now.Year + DateTime.Now.Month; CloseOnboardingCommand = new Command(new Action <object>(OnCloseOnboardingCommand)); GenerateMonthlyDataImgCommand = new Command(new Action <object>(OnGenerateMonthlyDataImgCommand)); Data = new StatisticModel(); Data.Year = DateTime.Now.Year; Data.Month = DateTime.Now.Month; Data.MonthRestData = new List <ChartDataModel>(); Data.MonthWorkData = new List <ChartDataModel>(); Data.MonthSkipData = new List <ChartDataModel>(); Data.WeekRestData = new List <ChartDataModel>(); Data.WeekWorkData = new List <ChartDataModel>(); Data.WeekSkipData = new List <ChartDataModel>(); Data.TomatoWeekData = new List <ChartDataModel>(); Data.PropertyChanged += Data_PropertyChanged; Data.IsAnimation = config.options.Style.IsAnimation; MigrateCheck(); HandleMonthData(); HandleWeekData(); Analysis(); }
public StatisticSummaryReportWindow(List <SummaryModel> records, List <SummaryModel> records2, StatisticModel Model) { this.Model = Model; InitializeComponent(); List <SummaryModel> removeRecord = new List <SummaryModel>(); foreach (var item in records) { if (item.Income == 0 && item.Spend == 0 && item.Profit == 0) { removeRecord.Add(item); } } foreach (var item in removeRecord) { records.Remove(item); } removeRecord.Clear(); foreach (var item in records2) { if (item.Income == 0 && item.Spend == 0 && item.Profit == 0) { removeRecord.Add(item); } } foreach (var item in removeRecord) { records2.Remove(item); } this.Text = Model.Title; Assembly asm = Assembly.LoadFrom(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Res.dll")); this.Icon = new Icon(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Statistic.ico")); krpbPrint.Click += (x, y) => { Print(); }; Model.DetailReport = records; Model.DetailReport2 = records2; SummaryReport report = new SummaryReport(Model.Parameters["PriceSymbol"].ToString()); webBrowser1.Refresh(); string htmlContent = report.ProcessHTMLContent(Model); webBrowser1.DocumentText = htmlContent; }
public async Task <IActionResult> Index() { var model = new StatisticModel(); model = await _transactionHistoryService.GetStatisticAsync(); return(View(model)); }
public IActionResult Statistic(string departmentName) { var department = dbContext.Departments.FirstOrDefault(d => d.Name.Equals(departmentName)); var model = new StatisticModel(dbContext); model = model.GetDepartmentStatistic(department); return(View(model)); }
/// <summary> /// Build Statistic from <c>StatisticModel</c> /// </summary> /// <param name="label">Name of Statistic</param> /// <param name="statisticFields">Value for statistic</param> /// <returns>Finished Statistic</returns> public static StatisticModel Build(string label, List <int> statisticFields) { var buildedStatistic = new StatisticModel(); buildedStatistic.Label = label; buildedStatistic.StatisticFields = statisticFields; return(buildedStatistic); }
private async void ResetStatistic() { await HttpClient.DeleteAsync("api/statistic"); currentLevelStatistic = await HttpClient.GetFromJsonAsync <StatisticModel>($"api/statistic/{selectedLevel}"); StateHasChanged(); }
/// <summary> /// GET: Формирует статистику /// </summary> /// <returns>Статистика</returns> public ActionResult Statistics() { var count = StatisticManager.GetVisitsByLastDay(); var visits = StatisticManager.GetGroupVisitsByTimeForLastDay(); var model = new StatisticModel(count, visits); return(View(model)); }
private async void OnSelectionChanged(ChangeEventArgs eventArgs) { selectedLevel = eventArgs.Value.ToString(); currentLevelStatistic = await HttpClient.GetFromJsonAsync <StatisticModel>($"api/statistic/{selectedLevel}"); currentLevelStatistic.BestGames = currentLevelStatistic.BestGames.OrderBy(r => r.DurationInSeconds).ToList(); StateHasChanged(); }
public StatisticViewModel(StatisticService statistic) { this.statistic = statistic; Data = new StatisticModel(); Data.Working = statistic.GetChartData(StatisticType.WorkingTime); Data.Reset = statistic.GetChartData(StatisticType.ResetTime); Data.Skip = statistic.GetChartData(StatisticType.SkipCount); Data.Labels = statistic.GetChartLabels(); }
public void CardSetting() { AnimalCount = StatisticModel.AnimalsInShelterSum(); AdoptionCount = StatisticModel.SuccessfullyAdoptedAnimals(); PlannedWalks = WalkModel.GetDatedWalks(DateTime.Today, DateTime.Today.AddYears(10)); LastAnimals = AnimalModel.LastAnimals(5); SetShelterInfo(); Filter(); }
public StatisticModel GetPersantageStatForProject(int projectId) { IList<StatisticModel> data = GetAvarageForAllProjectCases(projectId); int total = data.Sum(d => d.Total); var some = new StatisticModel { Skiped = data.Sum(d => d.Skiped), Failed = data.Sum(d => d.Failed), Done = data.Sum(d => d.Done), Total = total, }; return some; }