Пример #1
0
        // GET api/<controller>/
        public CalculationsViewModel Get()
        {
            var currentUser = User.Identity.Name;

            repo.GetAllActivitiesForCurrentUser(currentUser);
            var calcVM = new CalculationsViewModel();

            calcVM.totalHours   = repo.calculateYTDNumberHours(currentUser);
            calcVM.totalMileage = repo.calculateYTDMileage(currentUser);
            calcVM.totalDollars = repo.calculateYTDDollarsContributed(currentUser);
            return(calcVM);
        }
Пример #2
0
        // GET: Teams
        public ActionResult Index(int id = 1, Season season = (Season)1)
        {
            Teams team = _teamsRepository.AsQueryable().Where(s => s.TeamID == id).FirstOrDefault();

            teamCalc._team = team;
            PropertyInfo activityPropInfo = new Activity().GetType().GetProperty(team.Name.Replace(' ', '_').Replace('.', '_'));
            bool         isActive         = teamCalc.CheckIfTeamWasActive(activityPropInfo, season);

            int[]     points = new int[7];//null;
            TeamChart chart  = new TeamChart(team);

            if (isActive)
            {
                points            = teamCalc.GetSeasonRanking(null, season);
                ViewBag.ChartPath = chart.GenerateSeasonChart(points, season);
            }
            CalculationsViewModel viewModel = new CalculationsViewModel(team, points);

            ViewBag.Season            = (Season)season;
            ViewBag.SeasonDisplayName = Helpers.Helper.GetSeasonDisplayName(season);
            return(View(viewModel));
        }
Пример #3
0
        //
        // GET: /Manage/Index
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
                : message == ManageMessageId.Error ? "An error has occurred."
                : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
                : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
                : "";

            var userId = User.Identity.GetUserId();
            var model  = new CalculationsViewModel
            {
                HasPassword       = HasPassword(),
                PhoneNumber       = await UserManager.GetPhoneNumberAsync(userId),
                TwoFactor         = await UserManager.GetTwoFactorEnabledAsync(userId),
                Logins            = await UserManager.GetLoginsAsync(userId),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
            };

            return(View(model));
        }
Пример #4
0
        public CalculationsViewModel Calculate(DateTime startDate, DateTime endDate)
        {
            var calculateVM = new CalculationsViewModel();

            var people   = _context.Person.ToList();
            var expenses = _context.Expense.Where(x => x.issuedDate.Date >= startDate.Date &&
                                                  x.issuedDate.Date <= endDate.Date);

            //Get total of all expenses
            calculateVM.totalExpenses = expenses.Sum(x => x.amount);

            //Calculate total expenses for each person
            foreach (var person in people)
            {
                var calculationsPerPerson = new CalculationsPerPersonViewModel()
                {
                    personId = person.id,
                    total    = expenses.Where(x => x.personId == person.id).Sum(x => x.amount)
                };
                calculateVM.perPersonCalculations.Add(calculationsPerPerson);
            }

            return(calculateVM);
        }