Example #1
0
        public IActionResult MyAccount()
        {
            var  db          = new AdsDb(_connectionString);
            var  vm          = new AdsViewModel();
            User CurrentUser = db.GetByEmail(User.Identity.Name);

            vm.Ads = db.GetAds().Where(a => a.UserId == CurrentUser.Id).ToList();
            return(View(vm));
        }
Example #2
0
        public IActionResult Index()
        {
            var db = new AdsDb(_connectionString);
            var vm = new AdsViewModel();

            vm.Ads             = db.GetAds();
            vm.IsAuthenticated = User.Identity.IsAuthenticated;

            if (User.Identity.IsAuthenticated)
            {
                var email = User.Identity.Name;
                vm.CurrentUser = db.GetByEmail(email);
            }

            return(View(vm));
        }