Create Account View
This commit is contained in:
parent
d9208917f3
commit
72b29d9c78
|
@ -13,11 +13,18 @@ namespace FIT5032_Assignment
|
|||
{
|
||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||
|
||||
// Put Home folder into root route independently without keyword "Home"
|
||||
routes.MapRoute(
|
||||
name: "Home",
|
||||
url: "{action}/{id}",
|
||||
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
|
||||
/*routes.MapRoute(
|
||||
name: "Default",
|
||||
url: "{controller}/{action}/{id}",
|
||||
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,13 @@ namespace FIT5032_Assignment.Controllers
|
|||
return View();
|
||||
}
|
||||
|
||||
public ActionResult CreateAccount()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// POST /CreateAccount
|
||||
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
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 FIT5032_Assignment.Models;
|
||||
|
||||
namespace FIT5032_Assignment.Controllers
|
||||
{
|
||||
public class UsersController : Controller
|
||||
{
|
||||
private Database1Entities db = new Database1Entities();
|
||||
|
||||
// GET: Users
|
||||
public ActionResult Index()
|
||||
{
|
||||
var users = db.Users.Include(u => u.Doctors).Include(u => u.Patients);
|
||||
return View(users.ToList());
|
||||
}
|
||||
|
||||
// GET: Users/Details/5
|
||||
public ActionResult Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
||||
}
|
||||
Users users = db.Users.Find(id);
|
||||
if (users == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(users);
|
||||
}
|
||||
|
||||
// GET: Users/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
ViewBag.uuid = new SelectList(db.Doctors, "user", "bio");
|
||||
ViewBag.uuid = new SelectList(db.Patients, "user", "phone");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Users/Create
|
||||
// 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 Create([Bind(Include = "uuid,displayName,avatar,role")] Users users)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
db.Users.Add(users);
|
||||
db.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
ViewBag.uuid = new SelectList(db.Doctors, "user", "bio", users.uuid);
|
||||
ViewBag.uuid = new SelectList(db.Patients, "user", "phone", users.uuid);
|
||||
return View(users);
|
||||
}
|
||||
|
||||
// GET: Users/Edit/5
|
||||
public ActionResult Edit(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
||||
}
|
||||
Users users = db.Users.Find(id);
|
||||
if (users == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
ViewBag.uuid = new SelectList(db.Doctors, "user", "bio", users.uuid);
|
||||
ViewBag.uuid = new SelectList(db.Patients, "user", "phone", users.uuid);
|
||||
return View(users);
|
||||
}
|
||||
|
||||
// POST: Users/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 Edit([Bind(Include = "uuid,displayName,avatar,role")] Users users)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
db.Entry(users).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.uuid = new SelectList(db.Doctors, "user", "bio", users.uuid);
|
||||
ViewBag.uuid = new SelectList(db.Patients, "user", "phone", users.uuid);
|
||||
return View(users);
|
||||
}
|
||||
|
||||
// GET: Users/Delete/5
|
||||
public ActionResult Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
||||
}
|
||||
Users users = db.Users.Find(id);
|
||||
if (users == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(users);
|
||||
}
|
||||
|
||||
// POST: Users/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult DeleteConfirmed(string id)
|
||||
{
|
||||
Users users = db.Users.Find(id);
|
||||
db.Users.Remove(users);
|
||||
db.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
db.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -130,13 +130,13 @@
|
|||
<Compile Include="App_Start\FilterConfig.cs" />
|
||||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\UsersController.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\Appointments.cs">
|
||||
<DependentUpon>FIT5032-Assignment.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\CreateAccountForm.cs" />
|
||||
<Compile Include="Models\Credentials.cs">
|
||||
<DependentUpon>FIT5032-Assignment.tt</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -251,11 +251,7 @@
|
|||
<Content Include="Views\Home\About.cshtml" />
|
||||
<Content Include="Views\Home\Contact.cshtml" />
|
||||
<Content Include="Views\Home\Index.cshtml" />
|
||||
<Content Include="Views\Users\Create.cshtml" />
|
||||
<Content Include="Views\Users\Delete.cshtml" />
|
||||
<Content Include="Views\Users\Details.cshtml" />
|
||||
<Content Include="Views\Users\Edit.cshtml" />
|
||||
<Content Include="Views\Users\Index.cshtml" />
|
||||
<Content Include="Views\Home\CreateAccount.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
<WebStackScaffolding_DbContextTypeFullName>FIT5032_Assignment.Models.Database1Entities</WebStackScaffolding_DbContextTypeFullName>
|
||||
<WebStackScaffolding_IsViewGenerationSelected>True</WebStackScaffolding_IsViewGenerationSelected>
|
||||
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
|
||||
<View_SelectedScaffolderID>MvcViewScaffolder</View_SelectedScaffolderID>
|
||||
<View_SelectedScaffolderCategoryPath>root/Common/MVC/View</View_SelectedScaffolderCategoryPath>
|
||||
<WebStackScaffolding_ViewDialogWidth>600</WebStackScaffolding_ViewDialogWidth>
|
||||
</PropertyGroup>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
|
|
23
FIT5032-Assignment/Models/CreateAccountForm.cs
Normal file
23
FIT5032-Assignment/Models/CreateAccountForm.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace FIT5032_Assignment.Models
|
||||
{
|
||||
public class CreateAccountForm
|
||||
{
|
||||
[Required]
|
||||
[Display(Name = "Email address")]
|
||||
public string emailaddress { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Full name")]
|
||||
public string fullname { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Which role do you want to assign?")]
|
||||
public Int16 role { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,36 +1,34 @@
|
|||
@model FIT5032_Assignment.Models.Users
|
||||
@model FIT5032_Assignment.Models.CreateAccountForm
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Edit";
|
||||
ViewBag.Title = "CreateAccount";
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h2>Edit</h2>
|
||||
<h2>CreateAccount</h2>
|
||||
|
||||
|
||||
@using (Html.BeginForm())
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="form-horizontal">
|
||||
<h4>Users</h4>
|
||||
<h4>CreateAccountForm</h4>
|
||||
<hr />
|
||||
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
|
||||
@Html.HiddenFor(model => model.uuid)
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.displayName, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
@Html.LabelFor(model => model.emailaddress, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.displayName, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.displayName, "", new { @class = "text-danger" })
|
||||
@Html.EditorFor(model => model.emailaddress, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.emailaddress, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.avatar, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
@Html.LabelFor(model => model.fullname, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.avatar, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.avatar, "", new { @class = "text-danger" })
|
||||
@Html.EditorFor(model => model.fullname, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.fullname, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -44,7 +42,7 @@
|
|||
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Save" class="btn btn-default" />
|
||||
<input type="submit" value="Create" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,65 +0,0 @@
|
|||
@model FIT5032_Assignment.Models.Users
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Create";
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h2>Create</h2>
|
||||
|
||||
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="form-horizontal">
|
||||
<h4>Users</h4>
|
||||
<hr />
|
||||
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.uuid, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.uuid, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.uuid, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.displayName, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.displayName, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.displayName, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.avatar, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.avatar, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.avatar, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.role, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.role, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.role, "", 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>
|
||||
|
||||
@section Scripts {
|
||||
@Scripts.Render("~/bundles/jqueryval")
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
@model FIT5032_Assignment.Models.Users
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Delete";
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h2>Delete</h2>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Users</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.displayName)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.displayName)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.avatar)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.avatar)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.role)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.role)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Doctors.bio)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Doctors.bio)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Patients.phone)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Patients.phone)
|
||||
</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>
|
|
@ -1,59 +0,0 @@
|
|||
@model FIT5032_Assignment.Models.Users
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Details";
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h2>Details</h2>
|
||||
|
||||
<div>
|
||||
<h4>Users</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.displayName)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.displayName)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.avatar)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.avatar)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.role)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.role)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Doctors.bio)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Doctors.bio)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Patients.phone)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Patients.phone)
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
@Html.ActionLink("Edit", "Edit", new { id = Model.uuid }) |
|
||||
@Html.ActionLink("Back to List", "Index")
|
||||
</p>
|
|
@ -1,58 +0,0 @@
|
|||
@model IEnumerable<FIT5032_Assignment.Models.Users>
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Index";
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h2>Index</h2>
|
||||
|
||||
<p>
|
||||
@Html.ActionLink("Create New", "Create")
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.displayName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.avatar)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.role)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Doctors.bio)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Patients.phone)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.displayName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.avatar)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.role)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Doctors.bio)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Patients.phone)
|
||||
</td>
|
||||
<td>
|
||||
@Html.ActionLink("Edit", "Edit", new { id=item.uuid }) |
|
||||
@Html.ActionLink("Details", "Details", new { id=item.uuid }) |
|
||||
@Html.ActionLink("Delete", "Delete", new { id=item.uuid })
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
</table>
|
Loading…
Reference in New Issue
Block a user