//getting analytics data public AnalyticsDTO Analytic() { AnalyticsDTO bonus = new AnalyticsDTO(); bonus.MostTrending = tweetDBContextObject.MostTrending(); bonus.MostLiked = tweetDBContextObject.MostLiked(); bonus.MostTweetsBy = UserDBContextObject.MostTweetsBy(); bonus.TotalTweetsToday = tweetDBContextObject.TotalTweetsToday(); return(bonus); }
public AnalyticsDTO GetTopProductsByCat() { AnalyticsDTO analyticsDTO = productDatabaseContext.GetTopProductsByCat(); foreach (var category in analyticsDTO.Categories) { category.Products = category.Products.Take(4); } return(analyticsDTO); }
public AnalyticsDTO GetTopProductsByCat() { var Categories = dbContext.Category.Include(c => c.Product).OrderByDescending(c => c.ProductsSold).ToList(); foreach (var category in Categories) { category.Product = category.Product.OrderByDescending(p => p.QuantitySold).ToList(); } AnalyticsDTO analyticsDTO = new AnalyticsDTO(); analyticsDTO.Categories = _AnalyticsMapper.Map <IEnumerable <Category>, IEnumerable <CategoryProductsDTO> >(Categories); return(analyticsDTO); }
public ActionResult Index() { AnalyticsDTO analyticsDTO = new AnalyticsDTO(); ProductBusinessContext productBusinessContext = new ProductBusinessContext(); AnalyticsViewModel analyticsViewModel = new AnalyticsViewModel(); try { analyticsDTO = productBusinessContext.GetTopProductsByCart(); analyticsViewModel = AnalyticsMapper.Map <AnalyticsDTO, AnalyticsViewModel>(analyticsDTO); return(View(analyticsViewModel)); } catch (Exception ex) { return(View("InternalError" + ex)); } }
public AnalyticsDTO GetTopProductsByCart() { int counter = 0; AnalyticsDTO analyticsDTO = productDatabaseContext.GetTopProductsByCart(); foreach (var category in analyticsDTO.categoryProducts) { if (counter < 3) { category.Products = category.Products.Take(3); } else { category.Products = category.Products.Take(5); } counter++; } return(analyticsDTO); }
public AnalyticsDTO GetTopProductsByCart() { List <Category> categories = shoppingCartEntities.Categories.Include(c => c.Products).OrderByDescending(c => c.ProductsSold).ToList(); Debug.WriteLine(shoppingCartEntities.Categories.Include(c => c.Products).OrderByDescending(c => c.ProductsSold).ToList()); foreach (Category category in categories) { category.Products = category.Products.OrderByDescending(p => p.TotalVariantsSold).ToList(); Debug.WriteLine(category.Products.OrderByDescending(p => p.TotalVariantsSold).ToList()); IEnumerable <Product> products = category.Products; foreach (Product product in products) { IEnumerable <Variant> variants = product.Variants; } } AnalyticsDTO analyticsDTO = new AnalyticsDTO(); analyticsDTO.categoryProducts = AnalyticsMapper.Map <IEnumerable <Category>, IEnumerable <CategoryProductDTO> >(categories); return(analyticsDTO); }
/// <summary> /// sorts the data as per the requirement. /// top 3 categories with top 3 selling products at begining /// </summary> /// <returns></returns> public ActionResult Index() { try { IEnumerable <CategoryDTO> categoryDTOs; AnalyticsDTO analyticsDTO = new AnalyticsDTO(); ProductBusinessContext productBusinessContext = new ProductBusinessContext(); AnalyticsViewModel analyticsViewModel = new AnalyticsViewModel(); try { analyticsDTO = productBusinessContext.GetTopProductsByCart(); analyticsViewModel = AnalyticsMapper.Map <AnalyticsDTO, AnalyticsViewModel>(analyticsDTO); return(View(analyticsViewModel)); } catch (Exception ex) { return(RedirectToAction("ExceptionCatch", "Static", new { exception = ex.Message })); } }catch (Exception ex) { return(RedirectToAction("ExceptionCatch", "Static", new { exception = ex.Message })); } }
public ActionResult Index() { if (Session["UserID"] != null) { ViewBag.IsLoggedIn = "True"; } ProductBusinessContext productBusinessContext = new ProductBusinessContext(); //productBusinessContext.Changes(new Guid(Session["UserID"].ToString())); AnalyticsViewModel analyticsViewModel = new AnalyticsViewModel(); AnalyticsDTO analyticsDTO = new AnalyticsDTO(); try { analyticsDTO = productBusinessContext.GetTopProductsByCat(); analyticsViewModel = _AnalyticsMapper.Map <AnalyticsDTO, AnalyticsViewModel>(analyticsDTO); return(View(analyticsViewModel)); } catch (Exception) { return(View("Internal Error")); } }
public ActionResult <AnalyticsDTO> GetStatistics([FromQuery] Filter f) { var firstAidsDB = _context.FirstAid; var firstAids = ExecuteFilter(firstAidsDB, f); var ids = firstAids.Select(x => x.id).ToList(); var analytics = new AnalyticsDTO(); //byAge analytics.byAge = CalculateCombinationAgeAnalytics(firstAids, 1); //byEducation analytics.byEducation = CalculateCombinationAnalytics(firstAids, 2); //byCorrectSolution analytics.byCorrectSolution = CalculateCombinationAnalytics(firstAids, 3); //byHospitalization analytics.byHospitalization = CalculateCombinationAnalytics(firstAids, 4); //byMap var mapList = new List <Coordinates>(); foreach (var el in firstAids) { if (el.latitude != 0 && el.longitude != 0) { mapList.Add(new Coordinates(el.latitude, el.longitude)); } } analytics.byMap = new StatsMap(mapList); //byGender analytics.byGender = CalculateCombinationAnalytics(firstAids, 5).OrderBy(x => x.name).ToList(); //byNumberTraining analytics.byNumberTraining = CalculateCombinationAnalytics(firstAids, 6).OrderBy(x => x.name).ToList(); //byInjury var injuries = _context.Injury.ToList(); var fainjuries = _context.FAInjury.ToList(); fainjuries = fainjuries.Where(x => ids.Contains(x.FAId)).ToList(); var injuryList = new List <Combination>(); foreach (var el in injuries) { if (fainjuries.Where(x => x.IId == el.id).Count() > 0) { injuryList.Add(new Combination(el.name, fainjuries.Where(x => x.IId == el.id).Count())); } } analytics.byInjury = injuryList.OrderBy(x => x.name).ToList(); //byAssistance var assistances = _context.Assistance.ToList(); var faassistances = _context.FAAssistance.ToList(); faassistances = faassistances.Where(x => ids.Contains(x.FAId)).ToList(); var assistanceList = new List <Combination>(); foreach (var el in assistances) { if (faassistances.Where(x => x.AId == el.id).Count() > 0) { assistanceList.Add(new Combination(el.name, faassistances.Where(x => x.AId == el.id).Count())); } } analytics.byAssistance = assistanceList.OrderBy(x => x.name).ToList(); //byTraining var trainingList = new List <Combination>(); var trained = firstAids.Where(x => (x.hadFATraining == null) ? false : (bool)x.hadFATraining).ToList(); var rcTraining = trained.Where(x => (x.trainingByRC == null) ? false : (bool)x.trainingByRC).Count(); var otherTraining = trained.Where(x => (x.otherTrainingProvider == null) ? false : true).Count(); var bothTraining = firstAids.Where(x => (x.otherTrainingProvider == null || x.trainingByRC == null) ? false : (bool)x.hadFATraining).Count(); var noTraining = firstAids.Where(x => (x.hadFATraining == null) ? true : !(bool)x.hadFATraining).Count(); if (rcTraining > 0) { trainingList.Add(new Combination("Red Cross FA Training", rcTraining)); } if (otherTraining > 0) { trainingList.Add(new Combination("Other FA Training", otherTraining)); } if (bothTraining > 0) { trainingList.Add(new Combination("Red Cross & Other FA Training", bothTraining)); } if (noTraining > 0) { trainingList.Add(new Combination("No FA Training", noTraining)); } //byBlended analytics.byBlended = CalculateCombinationAnalytics(firstAids, 7); //byPercentProfHelp var byPhNeeded = CalculateCombinationAnalytics(firstAids, 8); analytics.byProfHelp = byPhNeeded; return(analytics); }
//Company public async Task <AnalyticsDTO> GetCompanyAnalytics(long companyId) { var analytics = new AnalyticsDTO(); var accepted = new List <ChartPointDTO>(); var declined = new List <ChartPointDTO>(); var date = GetMonthAndYear(); var month = date.Item1; var year = date.Item2; for (int i = 0; i < 12; i++) { accepted.Add(new ChartPointDTO { Name = Months[month], Value = GetCompanyBooksCount(month, year, BookStatus.Accepted, companyId) + GetCompanyBooksCount(month, year, BookStatus.Confirmed, companyId) + GetCompanyBooksCount(month, year, BookStatus.Finished, companyId) }); declined.Add(new ChartPointDTO { Name = Months[month], Value = GetCompanyBooksCount(month, year, BookStatus.Declined, companyId) }); month++; if (month > 12) { year++; month -= 12; } } analytics.BooksAccepted = new LineChartDTO { Name = "Accepted books", Series = accepted }; analytics.BooksDeclined = new LineChartDTO { Name = "Declined books", Series = declined }; var popularWorkPoints = await GetCompanyPopularWorks(companyId); analytics.PopularWorks = new PieChartDTO { Points = popularWorkPoints }; var confirmedWorks = await GetCompanyConfirmedWorks(companyId); analytics.ConfirmedWorks = new PieChartDTO { Points = confirmedWorks }; var decliendWorks = await GetCompanyDeclinedWorks(companyId); analytics.DeclinedWorks = new PieChartDTO { Points = decliendWorks }; var companyVendorsRating = await GetCompanyVendorsByRating(companyId); analytics.VendorsByRating = new PieChartDTO { Points = companyVendorsRating }; var companyVendorsBooks = await GetCompanyVendorsByOrders(companyId); analytics.VendorsByOrders = new PieChartDTO { Points = companyVendorsBooks }; var companyVendorsFinished = await GetCompanyVendorsByFinished(companyId); analytics.VendorsByFinished = new PieChartDTO { Points = companyVendorsFinished }; return(analytics); }