diff --git a/Cicm.Database/Models/News.cs b/Cicm.Database/Models/News.cs index 73ee639d..8f3bbd76 100644 --- a/Cicm.Database/Models/News.cs +++ b/Cicm.Database/Models/News.cs @@ -29,14 +29,16 @@ *******************************************************************************/ using System; +using System.ComponentModel; namespace Cicm.Database.Models { public class News { - public int Id { get; set; } - public DateTime Date { get; set; } - public NewsType Type { get; set; } - public int AddedId { get; set; } + public int Id { get; set; } + public DateTime Date { get; set; } + public NewsType Type { get; set; } + [DisplayName("Affected ID")] + public int AddedId { get; set; } } } \ No newline at end of file diff --git a/cicm_web/Areas/Admin/Controllers/NewsController.cs b/cicm_web/Areas/Admin/Controllers/NewsController.cs index af6f1ef7..60bae8a6 100644 --- a/cicm_web/Areas/Admin/Controllers/NewsController.cs +++ b/cicm_web/Areas/Admin/Controllers/NewsController.cs @@ -49,78 +49,8 @@ namespace cicm_web.Areas.Admin.Controllers } // GET: Admin/News - public async Task Index() => View(await _context.News.ToListAsync()); - - // GET: Admin/News/Details/5 - public async Task Details(int? id) - { - if(id == null) return NotFound(); - - News news = await _context.News.FirstOrDefaultAsync(m => m.Id == id); - if(news == null) return NotFound(); - - return View(news); - } - - // GET: Admin/News/Create - public IActionResult Create() => View(); - - // POST: Admin/News/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 Create([Bind("Id,Date,Type,AddedId")] News news) - { - if(ModelState.IsValid) - { - _context.Add(news); - await _context.SaveChangesAsync(); - return RedirectToAction(nameof(Index)); - } - - return View(news); - } - - // GET: Admin/News/Edit/5 - public async Task Edit(int? id) - { - if(id == null) return NotFound(); - - News news = await _context.News.FindAsync(id); - if(news == null) return NotFound(); - - return View(news); - } - - // POST: Admin/News/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 Edit(int id, [Bind("Id,Date,Type,AddedId")] News news) - { - if(id != news.Id) return NotFound(); - - if(ModelState.IsValid) - { - try - { - _context.Update(news); - await _context.SaveChangesAsync(); - } - catch(DbUpdateConcurrencyException) - { - if(!NewsExists(news.Id)) return NotFound(); - - throw; - } - - return RedirectToAction(nameof(Index)); - } - - return View(news); - } + public async Task Index() => + View(await _context.News.OrderByDescending(n => n.Date).ToListAsync()); // GET: Admin/News/Delete/5 public async Task Delete(int? id) diff --git a/cicm_web/Areas/Admin/Views/News/Create.cshtml b/cicm_web/Areas/Admin/Views/News/Create.cshtml deleted file mode 100644 index be95a664..00000000 --- a/cicm_web/Areas/Admin/Views/News/Create.cshtml +++ /dev/null @@ -1,59 +0,0 @@ -@{ - /****************************************************************************** -// Canary Islands Computer Museum Website -// ---------------------------------------------------------------------------- -// -// Filename : Create.cshtml -// Author(s) : Natalia Portillo -// -// --[ 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 . -// -// ---------------------------------------------------------------------------- -// Copyright © 2003-2018 Natalia Portillo -*******************************************************************************/ -} -@model Cicm.Database.Models.News - -@{ - ViewData["Title"] = "Create"; -} - -

Create

- -

News

-
-
-
-
-
-
- -
-
-
-
- - - -@section Scripts { - @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} -} diff --git a/cicm_web/Areas/Admin/Views/News/Details.cshtml b/cicm_web/Areas/Admin/Views/News/Details.cshtml deleted file mode 100644 index 9078589e..00000000 --- a/cicm_web/Areas/Admin/Views/News/Details.cshtml +++ /dev/null @@ -1,67 +0,0 @@ -@{ - /****************************************************************************** -// Canary Islands Computer Museum Website -// ---------------------------------------------------------------------------- -// -// Filename : Details.cshtml -// Author(s) : Natalia Portillo -// -// --[ Description ] ---------------------------------------------------------- -// -// Admin view details -// -// --[ 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 . -// -// ---------------------------------------------------------------------------- -// Copyright © 2003-2018 Natalia Portillo -*******************************************************************************/ -} -@model Cicm.Database.Models.News - -@{ - ViewData["Title"] = "Details"; -} - -

Details

- -
-

News

-
-
-
- @Html.DisplayNameFor(model => model.Date) -
-
- @Html.DisplayFor(model => model.Date) -
-
- @Html.DisplayNameFor(model => model.Type) -
-
- @Html.DisplayFor(model => model.Type) -
-
- @Html.DisplayNameFor(model => model.AddedId) -
-
- @Html.DisplayFor(model => model.AddedId) -
-
-
- diff --git a/cicm_web/Areas/Admin/Views/News/Edit.cshtml b/cicm_web/Areas/Admin/Views/News/Edit.cshtml deleted file mode 100644 index 4d1d0feb..00000000 --- a/cicm_web/Areas/Admin/Views/News/Edit.cshtml +++ /dev/null @@ -1,96 +0,0 @@ -@{ - /****************************************************************************** -// Canary Islands Computer Museum Website -// ---------------------------------------------------------------------------- -// -// Filename : Edit.cshtml -// Author(s) : Natalia Portillo -// -// --[ Description ] ---------------------------------------------------------- -// -// Admin view edit -// -// --[ 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 . -// -// ---------------------------------------------------------------------------- -// Copyright © 2003-2018 Natalia Portillo -*******************************************************************************/ -} -@model Cicm.Database.Models.News - -@{ - ViewData["Title"] = "Edit"; -} - -

Edit

- -

News

-
-
-
-
-
-
- -
- - - - -
-
- - - - -
-
- - - - -
- -
-
-
- -@section Scripts { - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } -} \ No newline at end of file diff --git a/cicm_web/Areas/Admin/Views/News/Index.cshtml b/cicm_web/Areas/Admin/Views/News/Index.cshtml index 7822bc36..ab71eb4e 100644 --- a/cicm_web/Areas/Admin/Views/News/Index.cshtml +++ b/cicm_web/Areas/Admin/Views/News/Index.cshtml @@ -38,12 +38,6 @@

News

-

- - Create New - -

@@ -73,16 +67,6 @@ @Html.DisplayFor(modelItem => item.AddedId)
- - Details - - - Edit - diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index c5938286..95629d2e 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.2 - 3.0.99.441 + 3.0.99.443 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website