예제 #1
0
        private void PrepareLookups(ClaimsPrincipal currentUser, ExpenseViewModel vm)
        {
            var userId = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;

            List <SelectListItem> accountidlist = vm.GetAccountList(userId);
            List <SelectListItem> items         = new List <SelectListItem>();

            foreach (var el in accountidlist)
            {
                items.Add(new SelectListItem {
                    Text = el.Text, Value = el.Value
                });
            }

            ViewBag.accountidlist = items;

            List <SelectListItem> categorylist = vm.GetCategoryExpenseList(userId);
            List <SelectListItem> categories   = new List <SelectListItem>();

            foreach (var el in categorylist)
            {
                categories.Add(new SelectListItem {
                    Text = el.Text, Value = el.Value
                });
            }

            ViewBag.categorylist = categories;

            List <SelectListItem> placelist = vm.GetPlaceList(userId);
            List <SelectListItem> places    = new List <SelectListItem>();

            foreach (var el in placelist)
            {
                places.Add(new SelectListItem {
                    Text = el.Text, Value = el.Value
                });
            }

            ViewBag.placelist = places;
        }