-
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.
Merge pull request #23 from guscatalano/catalda/views
make stuff happen - add controller and views for EvictionInfo
- Loading branch information
Showing
50 changed files
with
36,125 additions
and
9 deletions.
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
WlihaHackEviction/Controllers/EvictionInfoController.cs
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,152 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
using Microsoft.EntityFrameworkCore; | ||
using WlihaHackEviction.Models; | ||
|
||
namespace WlihaHackEviction.Controllers | ||
{ | ||
public class EvictionInfoController : Controller | ||
{ | ||
private readonly EvictionDatabaseContext _context; | ||
|
||
public EvictionInfoController(EvictionDatabaseContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
// GET: api/EvictionInfo | ||
public async Task<IActionResult> Index() | ||
{ | ||
return View(await _context.DBEvictionInfo.ToListAsync()); | ||
} | ||
|
||
// GET: EvictionInfo/Details/5 | ||
public async Task<IActionResult> Details(int? id) | ||
{ | ||
if (id == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
var evictionInfo = await _context.DBEvictionInfo | ||
.FirstOrDefaultAsync(m => m.Id == id); | ||
if (evictionInfo == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return View(evictionInfo); | ||
} | ||
|
||
// GET: EvictionInfo/Create | ||
public IActionResult Create() | ||
{ | ||
return View(); | ||
} | ||
|
||
// POST: EvictionInfo/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. | ||
[HttpPost] | ||
[ValidateAntiForgeryToken] | ||
public async Task<IActionResult> Create([Bind("Id,DateOfEviction,EvictionNotice,Lease,Verified,Notes,TenantId,AddressId,PreparerId")] EvictionInfo evictionInfo) | ||
{ | ||
if (ModelState.IsValid) | ||
{ | ||
_context.Add(evictionInfo); | ||
await _context.SaveChangesAsync(); | ||
return RedirectToAction(nameof(Index)); | ||
} | ||
return View(evictionInfo); | ||
} | ||
|
||
// GET: EvictionInfo/Edit/5 | ||
public async Task<IActionResult> Edit(int? id) | ||
{ | ||
if (id == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
var evictionInfo = await _context.DBEvictionInfo.FindAsync(id); | ||
if (evictionInfo == null) | ||
{ | ||
return NotFound(); | ||
} | ||
return View(evictionInfo); | ||
} | ||
|
||
// POST: EvictionInfo/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. | ||
[HttpPost] | ||
[ValidateAntiForgeryToken] | ||
public async Task<IActionResult> Edit(int id, [Bind("Id,DateOfEviction,EvictionNotice,Lease,Verified,Notes,TenantId,AddressId,PreparerId")] EvictionInfo evictionInfo) | ||
{ | ||
if (id != evictionInfo.Id) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
if (ModelState.IsValid) | ||
{ | ||
try | ||
{ | ||
_context.Update(evictionInfo); | ||
await _context.SaveChangesAsync(); | ||
} | ||
catch (DbUpdateConcurrencyException) | ||
{ | ||
if (!EvictionInfoExists(evictionInfo.Id)) | ||
{ | ||
return NotFound(); | ||
} | ||
else | ||
{ | ||
throw; | ||
} | ||
} | ||
return RedirectToAction(nameof(Index)); | ||
} | ||
return View(evictionInfo); | ||
} | ||
|
||
// GET: EvictionInfo/Delete/5 | ||
public async Task<IActionResult> Delete(int? id) | ||
{ | ||
if (id == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
var evictionInfo = await _context.DBEvictionInfo | ||
.FirstOrDefaultAsync(m => m.Id == id); | ||
if (evictionInfo == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return View(evictionInfo); | ||
} | ||
|
||
// POST: EvictionInfo/Delete/5 | ||
[HttpPost, ActionName("Delete")] | ||
[ValidateAntiForgeryToken] | ||
public async Task<IActionResult> DeleteConfirmed(int id) | ||
{ | ||
var evictionInfo = await _context.DBEvictionInfo.FindAsync(id); | ||
_context.DBEvictionInfo.Remove(evictionInfo); | ||
await _context.SaveChangesAsync(); | ||
return RedirectToAction(nameof(Index)); | ||
} | ||
|
||
private bool EvictionInfoExists(int id) | ||
{ | ||
return _context.DBEvictionInfo.Any(e => e.Id == id); | ||
} | ||
} | ||
} |
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,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace WlihaHackEviction.Models | ||
{ | ||
public class ErrorViewModel | ||
{ | ||
public string RequestId { get; set; } | ||
|
||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
} | ||
} |
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,68 @@ | ||
@model WlihaHackEviction.Models.EvictionInfo | ||
|
||
@{ | ||
ViewData["Title"] = "Create"; | ||
} | ||
|
||
<h1>Create</h1> | ||
|
||
<h4>EvictionInfo</h4> | ||
<hr /> | ||
<div class="row"> | ||
<div class="col-md-4"> | ||
<form asp-action="Create"> | ||
<div asp-validation-summary="ModelOnly" class="text-danger"></div> | ||
<div class="form-group"> | ||
<label asp-for="DateOfEviction" class="control-label"></label> | ||
<input asp-for="DateOfEviction" class="form-control" /> | ||
<span asp-validation-for="DateOfEviction" class="text-danger"></span> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="EvictionNotice" class="control-label"></label> | ||
<input asp-for="EvictionNotice" class="form-control" /> | ||
<span asp-validation-for="EvictionNotice" class="text-danger"></span> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="Lease" class="control-label"></label> | ||
<input asp-for="Lease" class="form-control" /> | ||
<span asp-validation-for="Lease" class="text-danger"></span> | ||
</div> | ||
<div class="form-group form-check"> | ||
<label class="form-check-label"> | ||
<input class="form-check-input" asp-for="Verified" /> @Html.DisplayNameFor(model => model.Verified) | ||
</label> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="Notes" class="control-label"></label> | ||
<input asp-for="Notes" class="form-control" /> | ||
<span asp-validation-for="Notes" class="text-danger"></span> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="TenantId" class="control-label"></label> | ||
<input asp-for="TenantId" class="form-control" /> | ||
<span asp-validation-for="TenantId" class="text-danger"></span> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="AddressId" class="control-label"></label> | ||
<input asp-for="AddressId" class="form-control" /> | ||
<span asp-validation-for="AddressId" class="text-danger"></span> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="PreparerId" class="control-label"></label> | ||
<input asp-for="PreparerId" class="form-control" /> | ||
<span asp-validation-for="PreparerId" class="text-danger"></span> | ||
</div> | ||
<div class="form-group"> | ||
<input type="submit" value="Create" class="btn btn-primary" /> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<a asp-action="Index">Back to List</a> | ||
</div> | ||
|
||
@section Scripts { | ||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");} | ||
} |
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,69 @@ | ||
@model WlihaHackEviction.Models.EvictionInfo | ||
|
||
@{ | ||
ViewData["Title"] = "Delete"; | ||
} | ||
|
||
<h1>Delete</h1> | ||
|
||
<h3>Are you sure you want to delete this?</h3> | ||
<div> | ||
<h4>EvictionInfo</h4> | ||
<hr /> | ||
<dl class="row"> | ||
<dt class = "col-sm-2"> | ||
@Html.DisplayNameFor(model => model.DateOfEviction) | ||
</dt> | ||
<dd class = "col-sm-10"> | ||
@Html.DisplayFor(model => model.DateOfEviction) | ||
</dd> | ||
<dt class = "col-sm-2"> | ||
@Html.DisplayNameFor(model => model.EvictionNotice) | ||
</dt> | ||
<dd class = "col-sm-10"> | ||
@Html.DisplayFor(model => model.EvictionNotice) | ||
</dd> | ||
<dt class = "col-sm-2"> | ||
@Html.DisplayNameFor(model => model.Lease) | ||
</dt> | ||
<dd class = "col-sm-10"> | ||
@Html.DisplayFor(model => model.Lease) | ||
</dd> | ||
<dt class = "col-sm-2"> | ||
@Html.DisplayNameFor(model => model.Verified) | ||
</dt> | ||
<dd class = "col-sm-10"> | ||
@Html.DisplayFor(model => model.Verified) | ||
</dd> | ||
<dt class = "col-sm-2"> | ||
@Html.DisplayNameFor(model => model.Notes) | ||
</dt> | ||
<dd class = "col-sm-10"> | ||
@Html.DisplayFor(model => model.Notes) | ||
</dd> | ||
<dt class = "col-sm-2"> | ||
@Html.DisplayNameFor(model => model.TenantId) | ||
</dt> | ||
<dd class = "col-sm-10"> | ||
@Html.DisplayFor(model => model.TenantId) | ||
</dd> | ||
<dt class = "col-sm-2"> | ||
@Html.DisplayNameFor(model => model.AddressId) | ||
</dt> | ||
<dd class = "col-sm-10"> | ||
@Html.DisplayFor(model => model.AddressId) | ||
</dd> | ||
<dt class = "col-sm-2"> | ||
@Html.DisplayNameFor(model => model.PreparerId) | ||
</dt> | ||
<dd class = "col-sm-10"> | ||
@Html.DisplayFor(model => model.PreparerId) | ||
</dd> | ||
</dl> | ||
|
||
<form asp-action="Delete"> | ||
<input type="hidden" asp-for="Id" /> | ||
<input type="submit" value="Delete" class="btn btn-danger" /> | | ||
<a asp-action="Index">Back to List</a> | ||
</form> | ||
</div> |
Oops, something went wrong.