public ActionResult IndexPost() { var random = new Random(); var viewModel = new ComparisonViewModel(null); TryUpdateModel(viewModel); Series[] series; if (!viewModel.AllIndexes) { series = new[] { this.GetSeries(viewModel.Query, viewModel.FirstIndex, random, viewModel.NumberOfQueries, viewModel.Data), this.GetSeries(viewModel.Query, viewModel.SecondIndex, random, viewModel.NumberOfQueries, viewModel.Data), }; } else { series = Enum.GetValues(typeof(IndexEnum)).OfType <IndexEnum>() .Select(t => this.GetSeries(viewModel.Query, t, random, viewModel.NumberOfQueries, viewModel.Data)).ToArray(); } DotNet.Highcharts.Highcharts chart = this.GetChart(series, viewModel.Data); viewModel.Chart = chart; var report = (Session["report"] as List <ReportViewModel>) ?? new List <ReportViewModel>(); report.Add(new ReportViewModel(viewModel, series)); Session["report"] = report; return(View(viewModel)); }
public IActionResult FindProducts(string lproductName, string rproductName) { var leftProduct = mainRepository.GetProductsByName(lproductName).FirstOrDefault(); var rightProduct = mainRepository.GetProductsByName(rproductName).FirstOrDefault(); int leftProductTagsCount = 0; int leftProductBoughtTimes = 0; long leftProductFileSize = 0; if (leftProduct != null) { leftProductTagsCount = mainRepository.GetTagsByProductID(leftProduct.ID).Count(); leftProductBoughtTimes = (from bp in mainRepository.GetAllBoughtProducts() where bp.ProductRefId == leftProduct.ID select bp).Count(); leftProductFileSize = leftProduct.GetFileSize(webHostEnvironment); } int rightProductTagsCount = 0; int rightProductBoughtTimes = 0; long rightProductFileSize = 0; if (rightProduct != null) { rightProductTagsCount = mainRepository.GetTagsByProductID(rightProduct.ID).Count(); rightProductBoughtTimes = (from bp in mainRepository.GetAllBoughtProducts() where bp.ProductRefId == rightProduct.ID select bp).Count(); rightProductFileSize = rightProduct.GetFileSize(webHostEnvironment); } var model = new ComparisonViewModel { LeftProduct = leftProduct, LeftProductName = lproductName, LeftProductTagsCount = leftProductTagsCount, LeftProductBoughtTimes = leftProductBoughtTimes, LeftProductFileSize = leftProductFileSize, RightProduct = rightProduct, RightProductName = rproductName, RightProductTagsCount = rightProductTagsCount, RightProductBoughtTimes = rightProductBoughtTimes, RightProductFileSize = rightProductFileSize }; if (rightProduct == null) { model.RightProductNotFound = true; } if (leftProduct == null) { model.LeftProductNotFound = true; } return(View("Comparison", model)); }
public ComparisonView() { InitializeComponent(); OxyPlotHelper.SetAxisZoomWheelAndPan(ComparisonPlotView); // Design time! if (DesignerProperties.GetIsInDesignMode(this)) { var appConfiguration = new CapFrameXConfiguration(); DataContext = new ComparisonViewModel(new FrametimeStatisticProvider(appConfiguration), new FrametimeAnalyzer(), new EventAggregator(), appConfiguration); } var context = SynchronizationContext.Current; (DataContext as ComparisonViewModel)?.ResetLShapeChart .ObserveOn(context) .SubscribeOn(context) .Subscribe(dummy => ResetLShapeChart()); }
public void GetStarsValueTest() { Assert.Equal((3.5f + 5f + 2f) / 3, ComparisonViewModel.GetStarsValue(mockUserComments)); }
public ActionResult Comparison(string course1, string course2) { var vm = new ComparisonViewModel(); var db = new CoursesEntities(); var firstCourse = db.Course.FirstOrDefault(x => x.Name == course1); var secondCourse = db.Course.FirstOrDefault(x => x.Name == course2); if (string.IsNullOrWhiteSpace(course1) || string.IsNullOrWhiteSpace(course2) || firstCourse.CourseID == secondCourse.CourseID) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var course1SKillIds = db.CourseSkill .Where(x => x.CourseID == firstCourse.CourseID) .Select(x => x.SkillID) .ToList(); var course2SKillIds = db.CourseSkill .Where(x => x.CourseID == secondCourse.CourseID) .Select(x => x.SkillID) .ToList(); var skills1 = db.Skills .Where(x => course1SKillIds.Contains(x.SkillID)) .Select(x => x.Name) .OrderBy(x => x) .ToList(); var skills2 = db.Skills .Where(x => course2SKillIds.Contains(x.SkillID)) .Select(x => x.Name) .OrderBy(x => x) .ToList(); var course1PositionIds = db.CoursePoosition .Where(x => x.CourseID == firstCourse.CourseID) .Select(x => x.PositionID) .ToList(); var course2PositionIds = db.CoursePoosition .Where(x => x.CourseID == secondCourse.CourseID) .Select(x => x.PositionID) .ToList(); var positions1 = db.Positions .Where(x => course1PositionIds.Contains(x.PositionID)) .Select(x => x.Name) .OrderBy(x => x) .ToList(); var positions2 = db.Positions .Where(x => course2PositionIds.Contains(x.PositionID)) .Select(x => x.Name) .OrderBy(x => x) .ToList(); var course1ProfFieldIds = db.CourseProfessionalField .Where(x => x.CourseID == firstCourse.CourseID) .Select(x => x.ProfessinalFieldID) .ToList(); var course2ProfFieldIds = db.CourseProfessionalField .Where(x => x.CourseID == secondCourse.CourseID) .Select(x => x.ProfessinalFieldID) .ToList(); var profFields1 = db.ProfessionalField .Where(x => course1ProfFieldIds.Contains(x.ProfessionalFieldID)) .Select(x => x.Name) .OrderBy(x => x) .ToList(); var profFields2 = db.ProfessionalField .Where(x => course2ProfFieldIds.Contains(x.ProfessionalFieldID)) .Select(x => x.Name) .OrderBy(x => x) .ToList(); vm.Course1 = firstCourse; vm.Course2 = secondCourse; vm.Course1SKills = SetUniqueItems(skills1, skills2); vm.Course2SKills = SetUniqueItems(skills2, skills1); vm.Course1Positions = SetUniqueItems(positions1, positions2); vm.Course2Positions = SetUniqueItems(positions2, positions1); vm.Course1ProfesionalFields = SetUniqueItems(profFields1, profFields2); vm.Course2ProfesionalFields = SetUniqueItems(profFields2, profFields1); return(View("ComparisonResult", vm)); }