public ActionResult Filter(string count, string type) { var countInt = GenericLogic.GetInt(count); var typeInt = GenericLogic.GetInt(type); var returnRecords = new List <ApplicationUser>(); var Companies = db.Users.Where(u => u.IsCompany).ToList(); if (typeInt.HasValue && countInt.HasValue) { switch (typeInt) { case 1: returnRecords = Companies.OrderByDescending(UserLogic.GetStarsForUser).Take(countInt.Value).ToList(); break; case 2: returnRecords = Companies.OrderByDescending(u => CurrencyLogic.ToBase(u.Contributions)).Take(countInt.Value).ToList(); break; //case 3: //default: // break; } } return(PartialView("_CorporatePartials", new Models.Companys.CompanySearchResultsVM() { CorporateResults = returnRecords, ShowSelector = true })); }
public ActionResult Details(string charityname) { var charity = db.Charities.FirstOrDefault(c => c.Name.ToLower().Replace(" ", "") == charityname.ToLower()); if (charity != null) { var DetailsVM = new CharityDetailsVM { CurrentPledges = db.OpenPledges.Where(p => p.CharityID == charity.ID).ToList(), Charity = charity }; var AllPledges = db.PledgeContributors.Where(c => c.Pledge.CharityID == charity.ID).ToList(); DetailsVM.TotalPledged = CurrencyLogic.ToBase(AllPledges); DetailsVM.NoOfPledges = AllPledges.Count(); var AllRaised = db.PledgeContributors.Where(c => c.Pledge.CharityID == charity.ID).ToList().Where(pc => PledgesLogic.GetPledgeStatus(pc.Pledge) == PledgesLogic.PledgeStatus.Completed).ToList(); DetailsVM.TotalRaised = CurrencyLogic.ToBase(AllRaised); DetailsVM.NoOfRaised = AllRaised.Count(); DetailsVM.UserPledgedChartData = CharityLogic.getUserPledgeContributionsForCharity(charity); DetailsVM.TeamPledgedChartData = CharityLogic.getTeamPledgeContributionsForCharity(charity); return(View(DetailsVM)); } Response.StatusCode = (int)HttpStatusCode.NotFound; return(Content("Charity not found", MediaTypeNames.Text.Plain)); }
public static ChartLogic.chartData getChartDataForSponsorshipPerUser(Team T) { var Labels = new List <ChartLogic.chartData.chartDataItem>(); var Series = new List <ChartLogic.chartData.chartDataItem>(); var Legends = new List <ChartLogic.chartData.chartDataItem>(); var UsersWithSponsorship = T.Members.Where(m => m.Contributions.Any()); foreach (var user in UsersWithSponsorship) { var Amt = user.Contributions.Sum(c => CurrencyLogic.ToBase(c.Currency, c.Amount)).ToString("0.00"); Labels.Add(new ChartLogic.chartData.chartDataItem(Amt)); Series.Add(new ChartLogic.chartData.chartDataItem(Amt)); Legends.Add(new ChartLogic.chartData.chartDataItem(user.UserName)); } return(new ChartLogic.chartData(Legends, Series, Labels, GenericLogic.HTML.SPONSORED_HTML + " Sponsored", true)); }
public static ChartLogic.chartData getChartDataForRaisedPerUser(Team T) { var Labels = new List <ChartLogic.chartData.chartDataItem>(); var Series = new List <ChartLogic.chartData.chartDataItem>(); var Legends = new List <ChartLogic.chartData.chartDataItem>(); var db = new ApplicationDbContext(); var UsersWithOffsets = T.Members.Where(m => m.Offsetters.Any()); foreach (var user in UsersWithOffsets) { var Amt = CurrencyLogic.ToBase(db.PledgeContributors.ToList().Where(c => c.Pledge.Offsets.Exists(o => o.Offsetter == user)).ToList()).ToString("0.00"); Labels.Add(new ChartLogic.chartData.chartDataItem(Amt)); Series.Add(new ChartLogic.chartData.chartDataItem(Amt)); Legends.Add(new ChartLogic.chartData.chartDataItem(user.UserName)); } return(new ChartLogic.chartData(Legends, Series, Labels, GenericLogic.HTML.RAISED_HTML + " Raised", true)); }
public static TeamActivityStats getActivityStatsForTeam(Team T) { var stats = new TeamActivityStats(); var db = new ApplicationDbContext(); var teamOffsets = db.Offsets.Where(o => o.Offsetter.Team.ID == T.ID).ToList(); var teamGroupedActivities = teamOffsets.GroupBy(o => o.Pledge.Activity_Units).ToList(); var calTotal = teamGroupedActivities.FirstOrDefault(g => g.Key == PledgeActivity.ActivityUnits.Calories)?.Sum(a => a.OffsetAmount); var HoursTotal = teamGroupedActivities.FirstOrDefault(g => g.Key == PledgeActivity.ActivityUnits.Hours)?.Sum(a => a.OffsetAmount); var MinutesTotal = teamGroupedActivities.FirstOrDefault(g => g.Key == PledgeActivity.ActivityUnits.Minutes)?.Sum(a => a.OffsetAmount); var KmetersTotal = teamGroupedActivities.FirstOrDefault(g => g.Key == PledgeActivity.ActivityUnits.Kilometers)?.Sum(a => a.OffsetAmount); var MetersTotal = teamGroupedActivities.FirstOrDefault(g => g.Key == PledgeActivity.ActivityUnits.Meters)?.Sum(a => a.OffsetAmount); var MilesTotal = teamGroupedActivities.FirstOrDefault(g => g.Key == PledgeActivity.ActivityUnits.Miles)?.Sum(a => a.OffsetAmount); var SessionsTotal = teamOffsets.Count(); stats.BaseCurrencySponsoredTotal = Math.Round(CurrencyLogic.ToBase(db.PledgeContributors.Where(pc => pc.Sinner.Team.ID == T.ID).ToList()), 2); stats.BaseCurrencyRaisedTotal = Math.Round(CurrencyLogic.ToBase(db.PledgeContributors.ToList().Where(pc => pc.Pledge.Offsets.Exists(o => o.Offsetter.Team?.ID == T.ID)).ToList()), 2); MetersTotal = MetersTotal.HasValue ? MetersTotal : 0; KmetersTotal = KmetersTotal.HasValue ? KmetersTotal : 0; MinutesTotal = MinutesTotal.HasValue ? MinutesTotal : 0; MilesTotal = MilesTotal.HasValue ? MilesTotal : 0; HoursTotal = HoursTotal.HasValue ? HoursTotal : 0; HoursTotal += (MinutesTotal / 60m); KmetersTotal += (MetersTotal / 1000.00m); MilesTotal += (KmetersTotal * 0.621m); stats.Calories = calTotal.HasValue ? Math.Round(calTotal.Value, 2) : 0; stats.Hours = HoursTotal.HasValue ? Math.Round(HoursTotal.Value, 2) : 0; stats.Miles = MilesTotal.HasValue ? Math.Round(MilesTotal.Value, 2) : 0; stats.Sessions = SessionsTotal; return(stats); }
public ActionResult Filter(string count, string type) { var countInt = GenericLogic.GetInt(count); var typeInt = GenericLogic.GetInt(type); var returnRecords = new List <Charity>(); //"Most Raised", "Most Activities", "Most Liked if (typeInt.HasValue && countInt.HasValue) { switch (typeInt) { case 1: returnRecords = db.Charities.ToList().OrderByDescending(c => c.Pledges.Sum(p => CurrencyLogic.ToBase(p.Contributors))).Take(countInt.Value).ToList(); break; case 2: returnRecords = db.Charities.OrderByDescending(c => c.Pledges.Sum(p => p.Offsets.Count())).Take(countInt.Value).ToList(); break; case 3: default: returnRecords = db.Charities.OrderByDescending(c => db.Likes.Count(l => l.LinkType == "Charity" && l.LinkID == c.ID.ToString())).Take(countInt.Value).ToList(); break; } } return(PartialView("_CharityPartials", new CharityListVM { Charities = returnRecords, ShowSelector = false, ShowSocial = true, ShowJustGivingLink = false })); }
// GET: Charities public ActionResult Index() { return (View(new CharityIndexVM { Charities = db.Charities.ToList().OrderByDescending(c => c.Pledges.Sum(p => CurrencyLogic.ToBase(p.Contributors))).Take(10).ToList() })); }