diff --git a/Marechai/Areas/Admin/Views/DocumentCompanies/Details.cshtml b/Marechai/Areas/Admin/Views/DocumentCompanies/Details.cshtml deleted file mode 100644 index 5698fd5e..00000000 --- a/Marechai/Areas/Admin/Views/DocumentCompanies/Details.cshtml +++ /dev/null @@ -1,33 +0,0 @@ -@model Marechai.ViewModels.DocumentCompanyViewModel - -@{ - ViewData["Title"] = "Details"; -} -

Details

-
-

Document company

-
-
-
- @Html.DisplayNameFor(model => model.Name) -
-
- @Html.DisplayFor(model => model.Name) -
-
- @Html.DisplayNameFor(model => model.Company) -
-
- - @Html.DisplayFor(modelItem => Model.Company) -
-
-
-
- - Edit - - - Back to List - -
\ No newline at end of file diff --git a/Marechai/Marechai.csproj b/Marechai/Marechai.csproj index 07c28e55..58ced25f 100644 --- a/Marechai/Marechai.csproj +++ b/Marechai/Marechai.csproj @@ -85,6 +85,9 @@ true + + true + <_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" /> diff --git a/Marechai/Pages/Admin/Details/DocumentCompany.razor b/Marechai/Pages/Admin/Details/DocumentCompany.razor new file mode 100644 index 00000000..102630b5 --- /dev/null +++ b/Marechai/Pages/Admin/Details/DocumentCompany.razor @@ -0,0 +1,69 @@ +@{ +/****************************************************************************** +// MARECHAI: Master repository of computing history artifacts information +// ---------------------------------------------------------------------------- +// +// 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-2020 Natalia Portillo +*******************************************************************************/ +} + +@page "/admin/document_companies/details/{Id:int}" +@inherits OwningComponentBase +@inject IStringLocalizer L +@inject CompaniesService CompaniesService +@attribute [Authorize(Roles = "UberAdmin, Admin")] +

@L["Document company details"]

+
+ +@if (!_loaded) +{ +

@L["Loading..."]

+ + return; +} + +
+ + @L["Name"] + + + @if (_editable || _model.CompanyId != null) + { + + @L["Linked company"] + + + } +
+
+ @L["Edit"] + @L["Back to list"] +
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/DocumentCompany.razor.cs b/Marechai/Pages/Admin/Details/DocumentCompany.razor.cs new file mode 100644 index 00000000..95d3096d --- /dev/null +++ b/Marechai/Pages/Admin/Details/DocumentCompany.razor.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Marechai.ViewModels; +using Microsoft.AspNetCore.Components; + +namespace Marechai.Pages.Admin.Details +{ + public partial class DocumentCompany + { + List _companies; + bool _editable; + bool _loaded; + Database.Models.DocumentCompany _model; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) + return; + + _loaded = true; + + if(Id <= 0) + return; + + _companies = await CompaniesService.GetAsync(); + _model = await Service.GetAsync(Id); + + StateHasChanged(); + } + } +} \ No newline at end of file diff --git a/Marechai/Pages/Admin/DocumentCompanies.razor b/Marechai/Pages/Admin/DocumentCompanies.razor index 648bd1b4..cf46a59e 100644 --- a/Marechai/Pages/Admin/DocumentCompanies.razor +++ b/Marechai/Pages/Admin/DocumentCompanies.razor @@ -71,9 +71,7 @@ - - @L["Details"] - + @L["Details"] @L["Edit"] diff --git a/Marechai/Resources/Services/DocumentCompaniesService.es.resx b/Marechai/Resources/Services/DocumentCompaniesService.es.resx index 677411e6..b3a1366d 100644 --- a/Marechai/Resources/Services/DocumentCompaniesService.es.resx +++ b/Marechai/Resources/Services/DocumentCompaniesService.es.resx @@ -162,4 +162,12 @@ Cancelar Cancel + + Detalles de compañía de documentos + Document company details + + + Volver a la lista + Back to list + \ No newline at end of file diff --git a/Marechai/Services/DocumentCompaniesService.cs b/Marechai/Services/DocumentCompaniesService.cs index 4b7b9f04..9db88c6e 100644 --- a/Marechai/Services/DocumentCompaniesService.cs +++ b/Marechai/Services/DocumentCompaniesService.cs @@ -22,6 +22,8 @@ namespace Marechai.Services CompanyId = d.CompanyId }).ToListAsync(); + public async Task GetAsync(int id) => await _context.DocumentCompanies.FindAsync(id); + public async Task DeleteAsync(int id) { DocumentCompany item = await _context.DocumentCompanies.FindAsync(id);