public IActionResult Signup(User u, string password) { var db = new AdsDB(_connectionString); db.AddUser(u, password); return(Redirect("/Account/Login")); }
public IActionResult Delete(int adId) { var db = new AdsDB(_connectionString); db.DeleteAd(adId); return(Redirect("/")); }
public IActionResult MyAcount() { var db = new AdsDB(_connectionString); int currentId = db.GetByEmail(User.Identity.Name).Id; return(Redirect($"/Home/index?id={currentId}")); }
public IActionResult NewAd(Ad a) { var db = new AdsDB(_connectionString); User u = db.GetByEmail(User.Identity.Name); db.AddAd(a, u); return(Redirect("/")); }
public IActionResult Index(int id) { var db = new AdsDB(_connectionString); var vm = new HomePageViewModel() { Ads = db.GetAds(id) }; if (User.Identity.IsAuthenticated) { vm.UserId = db.GetByEmail(User.Identity.Name).Id; } return(View(vm)); }
public IActionResult Login(string email, string password) { var db = new AdsDB(_connectionString); User u = db.Login(email, password); if (u == null) { TempData["message"] = "Invalid password/email combination. Try again"; return(Redirect("/Account/Login")); } var claims = new List <Claim> { new Claim("user", email) }; HttpContext.SignInAsync(new ClaimsPrincipal( new ClaimsIdentity("claims", "cookies", "role"))).Wait(); return(Redirect("/")); }