diff --git a/Controllers/AccountController.cs b/Controllers/AccountController.cs
new file mode 100644
index 0000000..256cdd5
--- /dev/null
+++ b/Controllers/AccountController.cs
@@ -0,0 +1,100 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using WebApplication1.Models;
+
+namespace WebApplication1.Controllers
+{
+ public class AccountController : Controller
+ {
+ newswebappEntities db = new newswebappEntities();
+
+ // GET: Account
+ public ActionResult Index()
+ {
+ return View();
+ }
+ public ActionResult Register()
+ {
+ ViewBag.Message = "Register page";
+
+ return View();
+ }
+ public ActionResult Login()
+ {
+ ViewBag.Message = "Login page";
+
+ return View();
+ }
+
+ [HttpPost]
+ public ActionResult Login(Login model)
+ {
+ // Replace this with actual authentication logic
+ if (ModelState.IsValid)
+ {
+ var allusers = db.users.ToList();
+
+ foreach (var user in allusers)
+ {
+ if (model.username == user.usename && model.password == user.password)
+ {
+ // Successful login, redirect to home page or desired page
+ return RedirectToAction("Index", "Home");
+ }
+ }
+ ModelState.AddModelError("", "Invalid username or password");
+ }
+ return View(model);
+ }
+ [HttpPost]
+ public ActionResult Register(Register model)
+ {
+ if (ModelState.IsValid)
+
+ {
+
+ // Replace this with actual user creation logic, including password hashing
+ // and storing user information in a database
+ /*var allusers = db.users.ToList();
+
+ foreach (var user in allusers)
+
+ {
+ if (model.username.ToString() == user.usename.ToString())
+ {
+ ModelState.AddModelError("", "username already exists");
+ return RedirectToAction("Register");
+ }
+ }*/
+
+ db.users.Add( new user
+ {
+ usename = model.username,
+ password = model.password,
+ displayname = model.displayname
+ });
+ db.SaveChanges();
+ return RedirectToAction("Home","Index");
+
+ }
+
+
+ /*db.users.Add(new user
+ {
+ usename = model.username,
+ password = model.password,
+ displayname = model.displayname
+ });
+ db.SaveChanges();
+ }*/
+
+ // return RedirectToAction("Login");
+
+ return View(model);
+ }
+ }
+}
+
\ No newline at end of file
diff --git a/Controllers/usersController.cs b/Controllers/usersController.cs
index b13e490..fa3c55e 100644
--- a/Controllers/usersController.cs
+++ b/Controllers/usersController.cs
@@ -197,12 +197,12 @@ namespace WebApplication1.Controllers
// POST: users/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
- public ActionResult DeleteConfirmed()
+ public ActionResult DeleteConfirmed(int id)
{
- user user = db.users.Find(Session["Userid"]);
+ user user = db.users.Find(id);
db.users.Remove(user);
db.SaveChanges();
- return Logout();
+ return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
diff --git a/WebApplication1.csproj b/WebApplication1.csproj
index 693ca22..a7f9555 100644
--- a/WebApplication1.csproj
+++ b/WebApplication1.csproj
@@ -142,6 +142,7 @@
+