diff --git a/Cicm.Database/Models/SoundByMachine.cs b/Cicm.Database/Models/SoundByMachine.cs index bf787eca..df180aed 100644 --- a/Cicm.Database/Models/SoundByMachine.cs +++ b/Cicm.Database/Models/SoundByMachine.cs @@ -28,6 +28,8 @@ // Copyright © 2003-2018 Natalia Portillo *******************************************************************************/ +using System.ComponentModel; + namespace Cicm.Database.Models { public class SoundByMachine @@ -37,6 +39,7 @@ namespace Cicm.Database.Models public long Id { get; set; } public virtual Machine Machine { get; set; } + [DisplayName("Sound synthetizer")] public virtual SoundSynth SoundSynth { get; set; } } } \ No newline at end of file diff --git a/cicm_web/Areas/Admin/Controllers/SoundByMachineController.cs b/cicm_web/Areas/Admin/Controllers/SoundByMachineController.cs new file mode 100644 index 00000000..8dacd8c8 --- /dev/null +++ b/cicm_web/Areas/Admin/Controllers/SoundByMachineController.cs @@ -0,0 +1,166 @@ +using System.Linq; +using System.Threading.Tasks; +using Cicm.Database.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.EntityFrameworkCore; + +namespace cicm_web.Areas.Admin.Controllers +{ + [Area("Admin")] + [Authorize] + public class SoundByMachineController : Controller + { + private readonly cicmContext _context; + + public SoundByMachineController(cicmContext context) + { + _context = context; + } + + // GET: SoundByMachine + public async Task Index() + { + var cicmContext = _context.SoundByMachine.Include(s => s.Machine).Include(s => s.SoundSynth); + return View(await cicmContext.OrderBy(s => s.Machine.Name).ThenBy(s => s.SoundSynth.Name).ToListAsync()); + } + + // GET: SoundByMachine/Details/5 + public async Task Details(long? id) + { + if (id == null) + { + return NotFound(); + } + + var soundByMachine = await _context.SoundByMachine + .Include(s => s.Machine) + .Include(s => s.SoundSynth) + .FirstOrDefaultAsync(m => m.Id == id); + if (soundByMachine == null) + { + return NotFound(); + } + + return View(soundByMachine); + } + + // GET: SoundByMachine/Create + public IActionResult Create() + { + ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name"); + ViewData["SoundSynthId"] = new SelectList(_context.SoundSynths, "Id", "Name"); + return View(); + } + + // POST: SoundByMachine/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("SoundSynthId,MachineId,Id")] SoundByMachine soundByMachine) + { + if (ModelState.IsValid) + { + _context.Add(soundByMachine); + await _context.SaveChangesAsync(); + return RedirectToAction(nameof(Index)); + } + ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", soundByMachine.MachineId); + ViewData["SoundSynthId"] = new SelectList(_context.SoundSynths, "Id", "Name", soundByMachine.SoundSynthId); + return View(soundByMachine); + } + + // GET: SoundByMachine/Edit/5 + public async Task Edit(long? id) + { + if (id == null) + { + return NotFound(); + } + + var soundByMachine = await _context.SoundByMachine.FindAsync(id); + if (soundByMachine == null) + { + return NotFound(); + } + ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", soundByMachine.MachineId); + ViewData["SoundSynthId"] = new SelectList(_context.SoundSynths, "Id", "Name", soundByMachine.SoundSynthId); + return View(soundByMachine); + } + + // POST: SoundByMachine/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(long id, [Bind("SoundSynthId,MachineId,Id")] SoundByMachine soundByMachine) + { + if (id != soundByMachine.Id) + { + return NotFound(); + } + + if (ModelState.IsValid) + { + try + { + _context.Update(soundByMachine); + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!SoundByMachineExists(soundByMachine.Id)) + { + return NotFound(); + } + else + { + throw; + } + } + return RedirectToAction(nameof(Index)); + } + ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", soundByMachine.MachineId); + ViewData["SoundSynthId"] = new SelectList(_context.SoundSynths, "Id", "Name", soundByMachine.SoundSynthId); + return View(soundByMachine); + } + + // GET: SoundByMachine/Delete/5 + public async Task Delete(long? id) + { + if (id == null) + { + return NotFound(); + } + + var soundByMachine = await _context.SoundByMachine + .Include(s => s.Machine) + .Include(s => s.SoundSynth) + .FirstOrDefaultAsync(m => m.Id == id); + if (soundByMachine == null) + { + return NotFound(); + } + + return View(soundByMachine); + } + + // POST: SoundByMachine/Delete/5 + [HttpPost, ActionName("Delete")] + [ValidateAntiForgeryToken] + public async Task DeleteConfirmed(long id) + { + var soundByMachine = await _context.SoundByMachine.FindAsync(id); + _context.SoundByMachine.Remove(soundByMachine); + await _context.SaveChangesAsync(); + return RedirectToAction(nameof(Index)); + } + + private bool SoundByMachineExists(long id) + { + return _context.SoundByMachine.Any(e => e.Id == id); + } + } +} diff --git a/cicm_web/Areas/Admin/Views/Home/Index.cshtml b/cicm_web/Areas/Admin/Views/Home/Index.cshtml index 6889c2a8..4dff0b39 100644 --- a/cicm_web/Areas/Admin/Views/Home/Index.cshtml +++ b/cicm_web/Areas/Admin/Views/Home/Index.cshtml @@ -54,6 +54,7 @@ Resolutions
Resolutions by GPU
Sound synthetizers
+ Sound synthetizers by machine
Storage by machines
diff --git a/cicm_web/Areas/Admin/Views/SoundByMachine/Create.cshtml b/cicm_web/Areas/Admin/Views/SoundByMachine/Create.cshtml new file mode 100644 index 00000000..400d62a6 --- /dev/null +++ b/cicm_web/Areas/Admin/Views/SoundByMachine/Create.cshtml @@ -0,0 +1,30 @@ +@model Cicm.Database.Models.SoundByMachine + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +

Sound by machine

+
+
+
+
+
+
+ + +
+
+ + +
+
+ + Back to List +
+
+
+
+ diff --git a/cicm_web/Areas/Admin/Views/SoundByMachine/Delete.cshtml b/cicm_web/Areas/Admin/Views/SoundByMachine/Delete.cshtml new file mode 100644 index 00000000..a7991567 --- /dev/null +++ b/cicm_web/Areas/Admin/Views/SoundByMachine/Delete.cshtml @@ -0,0 +1,33 @@ +@model Cicm.Database.Models.SoundByMachine + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

Sound by machine

+
+
+
+ @Html.DisplayNameFor(model => model.Machine) +
+
+ @Html.DisplayFor(model => model.Machine.Name) +
+
+ @Html.DisplayNameFor(model => model.SoundSynth) +
+
+ @Html.DisplayFor(model => model.SoundSynth.Name) +
+
+ +
+ + + Back to List +
+
diff --git a/cicm_web/Areas/Admin/Views/SoundByMachine/Details.cshtml b/cicm_web/Areas/Admin/Views/SoundByMachine/Details.cshtml new file mode 100644 index 00000000..ec969d05 --- /dev/null +++ b/cicm_web/Areas/Admin/Views/SoundByMachine/Details.cshtml @@ -0,0 +1,30 @@ +@model Cicm.Database.Models.SoundByMachine + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

Sound by machine

+
+
+
+ @Html.DisplayNameFor(model => model.Machine) +
+
+ @Html.DisplayFor(model => model.Machine.Name) +
+
+ @Html.DisplayNameFor(model => model.SoundSynth) +
+
+ @Html.DisplayFor(model => model.SoundSynth.Name) +
+
+
+ diff --git a/cicm_web/Areas/Admin/Views/SoundByMachine/Edit.cshtml b/cicm_web/Areas/Admin/Views/SoundByMachine/Edit.cshtml new file mode 100644 index 00000000..cc748cd2 --- /dev/null +++ b/cicm_web/Areas/Admin/Views/SoundByMachine/Edit.cshtml @@ -0,0 +1,33 @@ +@model Cicm.Database.Models.SoundByMachine + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +

Sound by machine

+
+
+
+
+
+
+ + + +
+
+ + + +
+ +
+ + Back to List +
+
+
+
+ diff --git a/cicm_web/Areas/Admin/Views/SoundByMachine/Index.cshtml b/cicm_web/Areas/Admin/Views/SoundByMachine/Index.cshtml new file mode 100644 index 00000000..b17f110c --- /dev/null +++ b/cicm_web/Areas/Admin/Views/SoundByMachine/Index.cshtml @@ -0,0 +1,41 @@ +@model IEnumerable + +@{ + ViewData["Title"] = "Index"; +} + +

Sound synthetizers by machine

+ +

+ Create New +

+ + + + + + + + + +@foreach (var item in Model) { + + + + + +} + +
+ @Html.DisplayNameFor(model => model.Machine) + + @Html.DisplayNameFor(model => model.SoundSynth) +
+ @Html.DisplayFor(modelItem => item.Machine.Name) + + @Html.DisplayFor(modelItem => item.SoundSynth.Name) + + Details + Edit + Delete +
diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index 2d9aa04c..eb25db61 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.2 - 3.0.99.479 + 3.0.99.483 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website