示例#1
0
        public IEnumerable <ApplicationUserDTO> ListAppUsers()
        {
            var appUsers = (from a in _repo.List()
                            select new ApplicationUserDTO
            {
                FirstName = a.FirstName,
                LastName = a.LastName,
                BirthDate = a.BirthDate,
                Height = a.Height,
                Weight = a.Weight,
                IsMale = a.IsMale
            });

            return(appUsers);
        }
示例#2
0
        //Get
        public ApplicationUserDTO ListUserInfo(string userName)
        {
            var user = (from u in _repo.List()
                        where u.UserName == userName
                        select new ApplicationUserDTO
            {
                Id = u.Id,
                MonthlyIncome = u.MonthlyIncome,
                MonthlyIncomeFixed = u.MonthlyIncomeFixed,
                //AddedToGoal = u.AddedToGoal,



                Budgets = (from b in u.Budgets
                           select new BudgetDTO
                {
                    Id = b.Id,
                    Amount = b.Amount,
                    Current = b.Current,
                    Name = b.Name
                }).ToList(),
                Goals = (from g in u.Goals select new GoalDTO
                {
                    Id = g.Id,
                    Amount = g.Amount,
                    Current = g.Current,
                    Name = g.Name,
                    EndDate = g.EndDate
                }).ToList()
            }).FirstOrDefault();

            user.CurrentTotal = user.MonthlyIncome - user.Budgets.Sum(t => t.Current);
            user.Spent        = user.MonthlyIncomeFixed - user.CurrentTotal;

            //user.CurrentTotal = user.MonthlyIncome - user.Budgets.Sum(t => t.Current);
            ////user.Spent = user.Budgets.Sum(s => s.Current + user.AddedToGoal);
            //user.Spent = user.MonthlyIncome - user.CurrentTotal;



            return(user);
        }