public IActionResult AddAccount(string name, string email, string password) { Adsdb db = new Adsdb(_connection); db.AddUser(name, email, password); return(Redirect("/account/login")); }
public IActionResult MyAccount(int id) { Adsdb db = new Adsdb(_connection); int userId = db.GetIdByEmail(User.Identity.Name); return(View(db.GetAds(userId))); }
public IActionResult CreateAd(Ad ad) { Adsdb db = new Adsdb(_connection); db.NewAd(ad); return(Redirect("/")); }
public IActionResult Delete(int id) { Adsdb db = new Adsdb(_connection); int userId = db.GetIdByEmail(User.Identity.Name); db.Delete(id, userId); return(Redirect("/")); }
public IActionResult Index() { Adsdb db = new Adsdb(_connection); AdView view = new AdView(); bool IsLoggedIn = User.Identity.IsAuthenticated; if (IsLoggedIn) { string email = User.Identity.Name; view.Id = db.GetIdByEmail(email); } view.Ads = db.GetAds(); return(View(view)); }
public IActionResult Login(string password, string email) { Adsdb db = new Adsdb(_connection); User u = db.Login(password, email); if (u == null) { TempData["Error"] = "Invalid Login Please Try Again"; return(Redirect("/account/login")); } var claims = new List <Claim> { new Claim("user", email) }; HttpContext.SignInAsync(new ClaimsPrincipal( new ClaimsIdentity(claims, "Cookies", "user", "role"))).Wait(); return(Redirect("/home/createad")); }