dlugolecki.net.pl
Dziennik
Polecane
Software
projects
/
wsti_pai.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Custom logging
[wsti_pai.git]
/
Projects
/
Controllers
/
ProjectsController.cs
diff --git
a/Projects/Controllers/ProjectsController.cs
b/Projects/Controllers/ProjectsController.cs
index 38271281c663b6c280ee06a6e1ec3d5077f7431f..ab93cc85bce70c71f4743b01ca85b7a49f649323 100644
(file)
--- a/
Projects/Controllers/ProjectsController.cs
+++ b/
Projects/Controllers/ProjectsController.cs
@@
-16,7
+16,7
@@
namespace Projects.Models
// GET: Projects
public ActionResult Index()
{
// GET: Projects
public ActionResult Index()
{
- var projects = db.Projects.Include(p => p.
Project
User);
+ var projects = db.Projects.Include(p => p.User);
return View(projects.ToList());
}
return View(projects.ToList());
}
@@
-36,31
+36,36
@@
namespace Projects.Models
}
// GET: Projects/Create
}
// GET: Projects/Create
+ [Authorize(Roles = "admin")]
public ActionResult Create()
{
public ActionResult Create()
{
- ViewBag.user_id = new SelectList(db.
Project
Users, "id", "login");
+ ViewBag.user_id = new SelectList(db.Users, "id", "login");
return View();
}
// POST: Projects/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
return View();
}
// POST: Projects/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
+ [Authorize(Roles = "admin")]
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost]
[ValidateAntiForgeryToken]
- public ActionResult Create([Bind(Include = "id,user_id,name,description
,created_at,updated_at
")] Project project)
+ public ActionResult Create([Bind(Include = "id,user_id,name,description")] Project project)
{
if (ModelState.IsValid)
{
{
if (ModelState.IsValid)
{
+ project.created_at = DateTime.Now;
+ project.updated_at = DateTime.Now;
db.Projects.Add(project);
db.SaveChanges();
return RedirectToAction("Index");
}
db.Projects.Add(project);
db.SaveChanges();
return RedirectToAction("Index");
}
- ViewBag.user_id = new SelectList(db.
Project
Users, "id", "login", project.user_id);
+ ViewBag.user_id = new SelectList(db.Users, "id", "login", project.user_id);
return View(project);
}
// GET: Projects/Edit/5
return View(project);
}
// GET: Projects/Edit/5
+ [Authorize(Roles = "admin")]
public ActionResult Edit(int? id)
{
if (id == null)
public ActionResult Edit(int? id)
{
if (id == null)
@@
-72,28
+77,31
@@
namespace Projects.Models
{
return HttpNotFound();
}
{
return HttpNotFound();
}
- ViewBag.user_id = new SelectList(db.
Project
Users, "id", "login", project.user_id);
+ ViewBag.user_id = new SelectList(db.Users, "id", "login", project.user_id);
return View(project);
}
// POST: Projects/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
return View(project);
}
// POST: Projects/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
+ [Authorize(Roles = "admin")]
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost]
[ValidateAntiForgeryToken]
- public ActionResult Edit([Bind(Include = "id,user_id,name,description,created_at
,updated_at
")] Project project)
+ public ActionResult Edit([Bind(Include = "id,user_id,name,description,created_at")] Project project)
{
if (ModelState.IsValid)
{
{
if (ModelState.IsValid)
{
+ project.updated_at = DateTime.Now;
db.Entry(project).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
db.Entry(project).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
- ViewBag.user_id = new SelectList(db.
Project
Users, "id", "login", project.user_id);
+ ViewBag.user_id = new SelectList(db.Users, "id", "login", project.user_id);
return View(project);
}
// GET: Projects/Delete/5
return View(project);
}
// GET: Projects/Delete/5
+ [Authorize(Roles = "admin")]
public ActionResult Delete(int? id)
{
if (id == null)
public ActionResult Delete(int? id)
{
if (id == null)
@@
-109,6
+117,7
@@
namespace Projects.Models
}
// POST: Projects/Delete/5
}
// POST: Projects/Delete/5
+ [Authorize(Roles = "admin")]
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)