Image upload page
This commit is contained in:
parent
35c458b236
commit
68966ed7d7
|
@ -249,14 +249,62 @@ namespace FIT5032_Assignment.Controllers {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult ImageUpload() {
|
public ActionResult ImageUpload() {
|
||||||
|
try {
|
||||||
|
if (Request.Cookies["psg_auth_token"] == null) {
|
||||||
|
// Redirect to home page
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
var user = loginVerify(Request.Cookies["psg_auth_token"].Value);
|
var user = loginVerify(Request.Cookies["psg_auth_token"].Value);
|
||||||
if (user != null) {
|
if (user == null) {
|
||||||
// Redirect to home page
|
// Redirect to home page
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
} else {
|
} else {
|
||||||
|
// Detect if user is doctor or patient
|
||||||
|
var db = new Database1Entities();
|
||||||
|
var credential = db.Credentials.Where(res => (res.uniqueIdCode == user) && (res.provider == 0));
|
||||||
|
if (credential.Count() == 0) {
|
||||||
|
// Redirect to create account
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
} else {
|
||||||
|
// Redirect to image upload
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e ) {
|
||||||
|
Trace.WriteLine(e);
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public ActionResult ImageUpload(Models.ImageUploadForm model) {
|
||||||
|
try {
|
||||||
|
if (Request.Cookies["psg_auth_token"] == null) {
|
||||||
|
// Redirect to home page
|
||||||
|
return new HttpStatusCodeResult(HttpStatusCode.Forbidden);
|
||||||
|
}
|
||||||
|
var user = loginVerify(Request.Cookies["psg_auth_token"].Value);
|
||||||
|
if (user == null) {
|
||||||
|
// Redirect to home page
|
||||||
|
return new HttpStatusCodeResult(HttpStatusCode.Forbidden);
|
||||||
|
} else {
|
||||||
|
// Detect if user is doctor or patient
|
||||||
|
var db = new Database1Entities();
|
||||||
|
var credential = db.Credentials.Where(res => (res.uniqueIdCode == user) && (res.provider == 0));
|
||||||
|
if (credential.Count() == 0) {
|
||||||
|
// return error 403
|
||||||
|
return new HttpStatusCodeResult(HttpStatusCode.Forbidden);
|
||||||
|
}
|
||||||
|
var dbUser = db.Users.Where(res => res.uuid == credential.First().user);
|
||||||
|
// print dbUser
|
||||||
|
Trace.WriteLine(dbUser.First());
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Trace.WriteLine(e);
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -188,6 +188,7 @@
|
||||||
<Compile Include="Models\Appointments.cs">
|
<Compile Include="Models\Appointments.cs">
|
||||||
<DependentUpon>FIT5032-Assignment.tt</DependentUpon>
|
<DependentUpon>FIT5032-Assignment.tt</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Models\ImageUploadForm.cs" />
|
||||||
<Compile Include="Models\CompleteProfileForm.cs" />
|
<Compile Include="Models\CompleteProfileForm.cs" />
|
||||||
<Compile Include="Models\Credentials.cs">
|
<Compile Include="Models\Credentials.cs">
|
||||||
<DependentUpon>FIT5032-Assignment.tt</DependentUpon>
|
<DependentUpon>FIT5032-Assignment.tt</DependentUpon>
|
||||||
|
|
14
FIT5032-Assignment/Models/ImageUploadForm.cs
Normal file
14
FIT5032-Assignment/Models/ImageUploadForm.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using System.Web;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace FIT5032_Assignment.Models {
|
||||||
|
public class ImageUploadForm {
|
||||||
|
[Required]
|
||||||
|
[Display(Name = "Assign to patient (email)")]
|
||||||
|
public string patientEmail { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[Display(Name = "Image file")]
|
||||||
|
public HttpPostedFileBase imageFile { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,13 +7,11 @@
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace FIT5032_Assignment.Models
|
namespace FIT5032_Assignment.Models {
|
||||||
{
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public partial class Images
|
public partial class Images {
|
||||||
{
|
|
||||||
public string uuid { get; set; }
|
public string uuid { get; set; }
|
||||||
public string patient { get; set; }
|
public string patient { get; set; }
|
||||||
public string responsibleBy { get; set; }
|
public string responsibleBy { get; set; }
|
||||||
|
|
|
@ -1,8 +1,42 @@
|
||||||
@{
|
@model FIT5032_Assignment.Models.ImageUploadForm
|
||||||
|
@{
|
||||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<main aria-labelledby="title">
|
@using (Html.BeginForm())
|
||||||
image upload
|
{
|
||||||
</main>
|
@Html.AntiForgeryToken()
|
||||||
|
|
||||||
|
<div class="form-horizontal">
|
||||||
|
<h4>Upload Image</h4>
|
||||||
|
<hr />
|
||||||
|
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
|
||||||
|
<div class="form-group">
|
||||||
|
@Html.LabelFor(model => model.patientEmail, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||||
|
<div class="col-md-10">
|
||||||
|
@Html.EditorFor(model => model.patientEmail, new { htmlAttributes = new { @class = "form-control" } })
|
||||||
|
@Html.ValidationMessageFor(model => model.patientEmail, "", new { @class = "text-danger" })
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
@Html.LabelFor(model => model.imageFile, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||||
|
<div class="col-md-10">
|
||||||
|
@Html.EditorFor(model => model.imageFile, new { htmlAttributes = new { @class = "form-control" } })
|
||||||
|
@Html.ValidationMessageFor(model => model.imageFile, "", 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>
|
||||||
|
}
|
||||||
|
|
||||||
|
@section Scripts {
|
||||||
|
@Scripts.Render("~/bundles/jqueryval")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user