diff --git a/Controllers/categoriesController.cs b/Controllers/categoriesController.cs index 555d33a..295134a 100644 --- a/Controllers/categoriesController.cs +++ b/Controllers/categoriesController.cs @@ -45,7 +45,7 @@ namespace WebApplication1.Controllers { if (Session["User"] != null) { - if (Convert.ToInt32(Session["Userrole"]) == 1) + if (Convert.ToInt32(Session["Userrole"]) > 0) { return View(); } @@ -81,7 +81,7 @@ namespace WebApplication1.Controllers { if (Session["User"] != null) { - if (Convert.ToInt32(Session["Userrole"]) == 1) + if (Convert.ToInt32(Session["Userrole"]) > 0) { if (id == null) { @@ -124,7 +124,7 @@ namespace WebApplication1.Controllers { if (Session["User"] != null) { - if (Convert.ToInt32(Session["Userrole"]) == 1) + if (Convert.ToInt32(Session["Userrole"]) > 0) { if (id == null) { diff --git a/Controllers/newsController.cs b/Controllers/newsController.cs index 945836d..264a34e 100644 --- a/Controllers/newsController.cs +++ b/Controllers/newsController.cs @@ -128,7 +128,10 @@ namespace WebApplication1.Controllers if (Request.Files.Count > 0) { setLists(); - + /* + string x = news.tag; + var y = news.tag[1]; + */ if (news.title != null && news.link != null && news.cat != null && news.tag != null) { var image = Request.Files[0]; @@ -202,7 +205,7 @@ namespace WebApplication1.Controllers { return HttpNotFound(); } - else if ( news.userID == Convert.ToInt32(Session["Userid"]) || Convert.ToInt32(Session["Userrole"]) == 1) + else if ( news.userID == Convert.ToInt32(Session["Userid"]) || Convert.ToInt32(Session["Userrole"]) > 0) { return View(news); } @@ -245,7 +248,7 @@ namespace WebApplication1.Controllers { return HttpNotFound(); } - else if (news.userID == Convert.ToInt32(Session["Userid"]) || Convert.ToInt32(Session["Userrole"]) == 1) + else if (news.userID == Convert.ToInt32(Session["Userid"]) || Convert.ToInt32(Session["Userrole"]) > 0) { return View(news); } diff --git a/Controllers/tagsController.cs b/Controllers/tagsController.cs index 88460bc..66d0aa8 100644 --- a/Controllers/tagsController.cs +++ b/Controllers/tagsController.cs @@ -44,7 +44,7 @@ namespace WebApplication1.Models { if (Session["User"] != null) { - if (Convert.ToInt32(Session["Userrole"]) == 1) + if (Convert.ToInt32(Session["Userrole"]) > 0) { return View(); } @@ -80,7 +80,7 @@ namespace WebApplication1.Models { if (Session["User"] != null) { - if (Convert.ToInt32(Session["Userrole"]) == 1) + if (Convert.ToInt32(Session["Userrole"]) > 0) { if (id == null) { @@ -123,7 +123,7 @@ namespace WebApplication1.Models { if (Session["User"] != null) { - if (Convert.ToInt32(Session["Userrole"]) == 1) + if (Convert.ToInt32(Session["Userrole"]) > 0) { if (id == null) { diff --git a/Controllers/usersController.cs b/Controllers/usersController.cs index c9b8746..e40b898 100644 --- a/Controllers/usersController.cs +++ b/Controllers/usersController.cs @@ -9,6 +9,7 @@ using System.Web.Mvc; using WebApplication1.Models; using System.Security.Cryptography; using System.Text; +using System.Web.UI.WebControls; namespace WebApplication1.Controllers { @@ -281,7 +282,52 @@ namespace WebApplication1.Controllers return View(user); } - + public ActionResult Edituser(int? id) + { + if (Session["User"] != null) + { + + if (Convert.ToInt32(Session["Userrole"]) == 1) + { + + if (id == null) + { + return new HttpStatusCodeResult(HttpStatusCode.BadRequest); + } + user user = db.users.Find(id); + if (user == null) + { + return HttpNotFound(); + } + return View(user); + } + else + return new HttpStatusCodeResult(HttpStatusCode.Unauthorized); + + } + else + return View("Login"); + } + + + // POST: tickets/Edit/5 + // To protect from overposting attacks, enable the specific properties you want to bind to, for + // more details see https://go.microsoft.com/fwlink/?LinkId=317598. + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Edituser([Bind(Include = "ID,usename,password,displayname,role")] user user) + { + if (ModelState.IsValid) + { + var currentuser = db.users.Find(user.ID); + currentuser.displayname = user.displayname; + currentuser.role = user.role; + db.SaveChanges(); + return RedirectToAction("Index"); + } + return View(user); + } + // GET: users/Delete/5 public ActionResult Delete(int? id) diff --git a/Media/news/kmcZj0sRbt.jpg b/Media/news/kmcZj0sRbt.jpg new file mode 100644 index 0000000..1d98158 Binary files /dev/null and b/Media/news/kmcZj0sRbt.jpg differ diff --git a/Views/categories/Details.cshtml b/Views/categories/Details.cshtml index c2fe6b4..7bacca0 100644 --- a/Views/categories/Details.cshtml +++ b/Views/categories/Details.cshtml @@ -34,7 +34,7 @@