public IActionResult MyAccount() { if (!User.Identity.IsAuthenticated) { return(Redirect("/account/logIn")); } SimpleAdsDb db = new SimpleAdsDb(_connectionString); var email = User.Identity.Name; var CurrentUser = db.GetByEmail(email); MyAccountViewModel vm = new MyAccountViewModel { Ads = db.MyAccount(CurrentUser.Id) }; return(View(vm)); }
public IActionResult Index() { SimpleAdsDb db = new SimpleAdsDb(_connectionString); HomeViewModel vm = new HomeViewModel { Ads = db.GetAllAds(), IsAuthenticated = User.Identity.IsAuthenticated }; if (User.Identity.IsAuthenticated) { var email = User.Identity.Name; vm.CurrentUser = db.GetByEmail(email); } return(View(vm)); }
public IActionResult NewAd() { if (!User.Identity.IsAuthenticated) { return(Redirect("/account/login")); } else { var email = User.Identity.Name; var db = new SimpleAdsDb(_connectionString); NewAdViewModel vm = new NewAdViewModel { User = db.GetByEmail(email) }; return(View(vm)); } }