Skip to content

Commit

Permalink
Merge pull request #23 from guscatalano/catalda/views
Browse files Browse the repository at this point in the history
make stuff happen - add controller and views for EvictionInfo
  • Loading branch information
snehashankar authored Jul 24, 2019
2 parents e821415 + 13dec9d commit 1ee4d7f
Show file tree
Hide file tree
Showing 50 changed files with 36,125 additions and 9 deletions.
152 changes: 152 additions & 0 deletions WlihaHackEviction/Controllers/EvictionInfoController.cs
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);
}
}
}
14 changes: 14 additions & 0 deletions WlihaHackEviction/Models/ErrorViewModel.cs
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);
}
}
18 changes: 9 additions & 9 deletions WlihaHackEviction/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using WlihaHackEviction.Models;
using Microsoft.OpenApi.Models;

Expand Down Expand Up @@ -55,11 +48,18 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
app.UseHsts();
}

app.UseStaticFiles();

app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"));

app.UseHttpsRedirection();
app.UseMvc();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
68 changes: 68 additions & 0 deletions WlihaHackEviction/Views/EvictionInfo/Create.cshtml
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");}
}
69 changes: 69 additions & 0 deletions WlihaHackEviction/Views/EvictionInfo/Delete.cshtml
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>
Loading

0 comments on commit 1ee4d7f

Please sign in to comment.