Do not allow to create browser tests.

This commit is contained in:
2019-05-18 14:50:28 +01:00
parent 0f29a8dded
commit 559931515e
3 changed files with 11 additions and 106 deletions

View File

@@ -62,29 +62,6 @@ namespace cicm_web.Areas.Admin.Controllers
return View(browserTest); return View(browserTest);
} }
// GET: Admin/BrowserTests/Create
public IActionResult Create() => View();
// POST: Admin/BrowserTests/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,UserAgent,Browser,Version,Os,Platform,Gif87,Gif89,Jpeg,Png,Pngt,Agif,Table,Colors,Js,Frames,Flash")]
BrowserTest browserTest)
{
if(ModelState.IsValid)
{
_context.Add(browserTest);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(browserTest);
}
// GET: Admin/BrowserTests/Edit/5 // GET: Admin/BrowserTests/Edit/5
public async Task<IActionResult> Edit(int? id) public async Task<IActionResult> Edit(int? id)
{ {
@@ -108,8 +85,8 @@ namespace cicm_web.Areas.Admin.Controllers
{ {
if(id != browserTest.Id) return NotFound(); if(id != browserTest.Id) return NotFound();
if(ModelState.IsValid) if(!ModelState.IsValid) return View(browserTest);
{
try try
{ {
_context.Update(browserTest); _context.Update(browserTest);
@@ -125,9 +102,6 @@ namespace cicm_web.Areas.Admin.Controllers
return RedirectToAction(nameof(Index)); return RedirectToAction(nameof(Index));
} }
return View(browserTest);
}
// GET: Admin/BrowserTests/Delete/5 // GET: Admin/BrowserTests/Delete/5
public async Task<IActionResult> Delete(int? id) public async Task<IActionResult> Delete(int? id)
{ {

View File

@@ -1,63 +0,0 @@
@{
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : Create.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Admin view create
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/
}
@model Cicm.Database.Models.BrowserTest
@{
ViewData["Title"] = "Create";
}
<h2>Create</h2>
<h4>Browser test</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">
<input class="btn btn-primary"
type="submit"
value="Create" />
<a asp-action="Index"
class="btn btn-secondary">
Back to List
</a>
</div>
</form>
</div>
</div>
@section Scripts {
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@@ -38,12 +38,6 @@
<h2>Browser tests</h2> <h2>Browser tests</h2>
<p>
<a asp-action="Create"
class="btn btn-primary">
Create New
</a>
</p>
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>