-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a245fd9
commit f6e1876
Showing
9 changed files
with
459 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,7 @@ a:link { | |
|
||
/* visited link */ | ||
a:visited { | ||
color: azure; | ||
color: #E7717D; | ||
} | ||
|
||
/* mouse over link */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Data.Entity; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
using TheCatProject.DAL; | ||
using TheCatProject.Models; | ||
|
||
namespace TheCatProject.Controllers | ||
{ | ||
public class PTagsController : Controller | ||
{ | ||
private CatsContext db = new CatsContext(); | ||
|
||
// GET: PTags | ||
public ActionResult Index() | ||
{ | ||
var pTags = db.PTags.Include(p => p.Cat).Include(p => p.Personality).Include(p => p.Personality1).Include(p => p.Personality2); | ||
return View(pTags.ToList()); | ||
} | ||
|
||
// GET: PTags/Details/5 | ||
public ActionResult Details(int? id) | ||
{ | ||
if (id == null) | ||
{ | ||
return new HttpStatusCodeResult(HttpStatusCode.BadRequest); | ||
} | ||
PTag pTag = db.PTags.Find(id); | ||
if (pTag == null) | ||
{ | ||
return HttpNotFound(); | ||
} | ||
return View(pTag); | ||
} | ||
|
||
// GET: PTags/Create | ||
public ActionResult Create() | ||
{ | ||
ViewBag.CID = new SelectList(db.Cats, "ID", "Name"); | ||
ViewBag.FirstTrait = new SelectList(db.Personalities, "ID", "Type"); | ||
ViewBag.SecondTrait = new SelectList(db.Personalities, "ID", "Type"); | ||
ViewBag.ThirdTrait = new SelectList(db.Personalities, "ID", "Type"); | ||
return View(); | ||
} | ||
|
||
// POST: PTags/Create | ||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for | ||
// more details see https://go.microsoft.com/fwlink/?LinkId=317598. | ||
[HttpPost] | ||
[ValidateAntiForgeryToken] | ||
public ActionResult Create([Bind(Include = "ID,CID,FirstTrait,SecondTrait,ThirdTrait")] PTag pTag) | ||
{ | ||
if (ModelState.IsValid) | ||
{ | ||
db.PTags.Add(pTag); | ||
db.SaveChanges(); | ||
return RedirectToAction("Index"); | ||
} | ||
|
||
ViewBag.CID = new SelectList(db.Cats, "ID", "Name", pTag.CID); | ||
ViewBag.FirstTrait = new SelectList(db.Personalities, "ID", "Type", pTag.FirstTrait); | ||
ViewBag.SecondTrait = new SelectList(db.Personalities, "ID", "Type", pTag.SecondTrait); | ||
ViewBag.ThirdTrait = new SelectList(db.Personalities, "ID", "Type", pTag.ThirdTrait); | ||
return View(pTag); | ||
} | ||
|
||
// GET: PTags/Edit/5 | ||
public ActionResult Edit(int? id) | ||
{ | ||
if (id == null) | ||
{ | ||
return new HttpStatusCodeResult(HttpStatusCode.BadRequest); | ||
} | ||
PTag pTag = db.PTags.Find(id); | ||
if (pTag == null) | ||
{ | ||
return HttpNotFound(); | ||
} | ||
ViewBag.CID = new SelectList(db.Cats, "ID", "Name", pTag.CID); | ||
ViewBag.FirstTrait = new SelectList(db.Personalities, "ID", "Type", pTag.FirstTrait); | ||
ViewBag.SecondTrait = new SelectList(db.Personalities, "ID", "Type", pTag.SecondTrait); | ||
ViewBag.ThirdTrait = new SelectList(db.Personalities, "ID", "Type", pTag.ThirdTrait); | ||
return View(pTag); | ||
} | ||
|
||
// POST: PTags/Edit/5 | ||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for | ||
// more details see https://go.microsoft.com/fwlink/?LinkId=317598. | ||
[HttpPost] | ||
[ValidateAntiForgeryToken] | ||
public ActionResult Edit([Bind(Include = "ID,CID,FirstTrait,SecondTrait,ThirdTrait")] PTag pTag) | ||
{ | ||
if (ModelState.IsValid) | ||
{ | ||
db.Entry(pTag).State = EntityState.Modified; | ||
db.SaveChanges(); | ||
return RedirectToAction("Index"); | ||
} | ||
ViewBag.CID = new SelectList(db.Cats, "ID", "Name", pTag.CID); | ||
ViewBag.FirstTrait = new SelectList(db.Personalities, "ID", "Type", pTag.FirstTrait); | ||
ViewBag.SecondTrait = new SelectList(db.Personalities, "ID", "Type", pTag.SecondTrait); | ||
ViewBag.ThirdTrait = new SelectList(db.Personalities, "ID", "Type", pTag.ThirdTrait); | ||
return View(pTag); | ||
} | ||
|
||
// GET: PTags/Delete/5 | ||
public ActionResult Delete(int? id) | ||
{ | ||
if (id == null) | ||
{ | ||
return new HttpStatusCodeResult(HttpStatusCode.BadRequest); | ||
} | ||
PTag pTag = db.PTags.Find(id); | ||
if (pTag == null) | ||
{ | ||
return HttpNotFound(); | ||
} | ||
return View(pTag); | ||
} | ||
|
||
// POST: PTags/Delete/5 | ||
[HttpPost, ActionName("Delete")] | ||
[ValidateAntiForgeryToken] | ||
public ActionResult DeleteConfirmed(int id) | ||
{ | ||
PTag pTag = db.PTags.Find(id); | ||
db.PTags.Remove(pTag); | ||
db.SaveChanges(); | ||
return RedirectToAction("Index"); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (disposing) | ||
{ | ||
db.Dispose(); | ||
} | ||
base.Dispose(disposing); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
@model TheCatProject.Models.PTag | ||
|
||
@{ | ||
ViewBag.Title = "Create"; | ||
} | ||
|
||
<h2>Create</h2> | ||
|
||
@using (Html.BeginForm()) | ||
{ | ||
@Html.AntiForgeryToken() | ||
|
||
<div class="form-horizontal"> | ||
<h4>PTag</h4> | ||
<hr /> | ||
@Html.ValidationSummary(true, "", new { @class = "text-danger" }) | ||
<div class="form-group"> | ||
@Html.LabelFor(model => model.CID, "CID", htmlAttributes: new { @class = "control-label col-md-2" }) | ||
<div class="col-md-10"> | ||
@Html.DropDownList("CID", null, htmlAttributes: new { @class = "form-control" }) | ||
@Html.ValidationMessageFor(model => model.CID, "", new { @class = "text-danger" }) | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
@Html.LabelFor(model => model.FirstTrait, "FirstTrait", htmlAttributes: new { @class = "control-label col-md-2" }) | ||
<div class="col-md-10"> | ||
@Html.DropDownList("FirstTrait", null, htmlAttributes: new { @class = "form-control" }) | ||
@Html.ValidationMessageFor(model => model.FirstTrait, "", new { @class = "text-danger" }) | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
@Html.LabelFor(model => model.SecondTrait, "SecondTrait", htmlAttributes: new { @class = "control-label col-md-2" }) | ||
<div class="col-md-10"> | ||
@Html.DropDownList("SecondTrait", null, htmlAttributes: new { @class = "form-control" }) | ||
@Html.ValidationMessageFor(model => model.SecondTrait, "", new { @class = "text-danger" }) | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
@Html.LabelFor(model => model.ThirdTrait, "ThirdTrait", htmlAttributes: new { @class = "control-label col-md-2" }) | ||
<div class="col-md-10"> | ||
@Html.DropDownList("ThirdTrait", null, htmlAttributes: new { @class = "form-control" }) | ||
@Html.ValidationMessageFor(model => model.ThirdTrait, "", new { @class = "text-danger" }) | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<div class="col-md-offset-2 col-md-10"> | ||
<input type="submit" value="Create" class="btn btn-default" /> | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
|
||
<div> | ||
@Html.ActionLink("Back to List", "Index") | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
@model TheCatProject.Models.PTag | ||
|
||
@{ | ||
ViewBag.Title = "Delete"; | ||
} | ||
|
||
<h2>Delete</h2> | ||
|
||
<h3>Are you sure you want to delete this?</h3> | ||
<div> | ||
<h4>PTag</h4> | ||
<hr /> | ||
<dl class="dl-horizontal"> | ||
<dt> | ||
@Html.DisplayNameFor(model => model.Cat.Name) | ||
</dt> | ||
|
||
<dd> | ||
@Html.DisplayFor(model => model.Cat.Name) | ||
</dd> | ||
|
||
<dt> | ||
@Html.DisplayNameFor(model => model.Personality.Type) | ||
</dt> | ||
|
||
<dd> | ||
@Html.DisplayFor(model => model.Personality.Type) | ||
</dd> | ||
|
||
<dt> | ||
@Html.DisplayNameFor(model => model.Personality1.Type) | ||
</dt> | ||
|
||
<dd> | ||
@Html.DisplayFor(model => model.Personality1.Type) | ||
</dd> | ||
|
||
<dt> | ||
@Html.DisplayNameFor(model => model.Personality2.Type) | ||
</dt> | ||
|
||
<dd> | ||
@Html.DisplayFor(model => model.Personality2.Type) | ||
</dd> | ||
|
||
</dl> | ||
|
||
@using (Html.BeginForm()) { | ||
@Html.AntiForgeryToken() | ||
|
||
<div class="form-actions no-color"> | ||
<input type="submit" value="Delete" class="btn btn-default" /> | | ||
@Html.ActionLink("Back to List", "Index") | ||
</div> | ||
} | ||
</div> |
Oops, something went wrong.