diff --git a/Marechai.Database/Models/MarechaiContext.cs b/Marechai.Database/Models/MarechaiContext.cs index 566ef23e..13d8c5b4 100644 --- a/Marechai.Database/Models/MarechaiContext.cs +++ b/Marechai.Database/Models/MarechaiContext.cs @@ -103,7 +103,7 @@ namespace Marechai.Database.Models return; #warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http: //go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings. - optionsBuilder.UseMySql("server=localhost;port=3306;user=marechai;password=marechaipass;database=marechai"); + optionsBuilder.UseMySql("server=zeus.claunia.com;port=3306;user=marechai;password=marechaipass;database=marechai"); optionsBuilder.UseLazyLoadingProxies(); } diff --git a/Marechai/Areas/Admin/Views/Companies/Details.cshtml b/Marechai/Areas/Admin/Views/Companies/Details.cshtml deleted file mode 100644 index 0d9c351a..00000000 --- a/Marechai/Areas/Admin/Views/Companies/Details.cshtml +++ /dev/null @@ -1,125 +0,0 @@ -@{ - /****************************************************************************** -// 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 -*******************************************************************************/ -} -@model Marechai.Database.Models.Company - -@{ - ViewData["Title"] = "Details"; -} -

Details

-
-

Company

-
-
-
- @Html.DisplayNameFor(model => model.Name) -
-
- @Html.DisplayFor(model => model.Name) -
-
- @Html.DisplayNameFor(model => model.Founded) -
-
- @Html.DisplayFor(model => model.Founded) -
-
- @Html.DisplayNameFor(model => model.Website) -
-
- @Html.DisplayFor(model => model.Website) -
-
- @Html.DisplayNameFor(model => model.Twitter) -
-
- @Html.DisplayFor(model => model.Twitter) -
-
- @Html.DisplayNameFor(model => model.Facebook) -
-
- @Html.DisplayFor(model => model.Facebook) -
-
- @Html.DisplayNameFor(model => model.Sold) -
-
- @Html.DisplayFor(model => model.Sold) -
-
- @Html.DisplayNameFor(model => model.Address) -
-
- @Html.DisplayFor(model => model.Address) -
-
- @Html.DisplayNameFor(model => model.City) -
-
- @Html.DisplayFor(model => model.City) -
-
- @Html.DisplayNameFor(model => model.Province) -
-
- @Html.DisplayFor(model => model.Province) -
-
- @Html.DisplayNameFor(model => model.PostalCode) -
-
- @Html.DisplayFor(model => model.PostalCode) -
-
- @Html.DisplayNameFor(model => model.Status) -
-
- @Html.DisplayFor(model => model.Status) -
-
- @Html.DisplayNameFor(model => model.Country) -
-
- @Html.DisplayFor(model => model.Country.Name) -
-
- @Html.DisplayNameFor(model => model.SoldTo) -
-
- @Html.DisplayFor(model => model.SoldTo.Name) -
-
-
-
- Edit - Back to List -
\ No newline at end of file diff --git a/Marechai/Marechai.csproj b/Marechai/Marechai.csproj index 0ef8be6e..419d7f83 100644 --- a/Marechai/Marechai.csproj +++ b/Marechai/Marechai.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 3.0.99.1100 + 3.0.99.1159 Canary Islands Computer Museum Copyright © 2003-2020 Natalia Portillo Canary Islands Computer Museum Website @@ -16,8 +16,8 @@ - - + + diff --git a/Marechai/Pages/Admin/Companies.razor b/Marechai/Pages/Admin/Companies.razor index 8c6d7f00..e435286f 100644 --- a/Marechai/Pages/Admin/Companies.razor +++ b/Marechai/Pages/Admin/Companies.razor @@ -33,6 +33,7 @@ @page "/admin/companies" @inherits OwningComponentBase @inject IStringLocalizer L + @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Companies"]

@if (_companies is null) @@ -88,9 +89,7 @@ @item.SoldTo - - @L["Details"] - + @L["Details"] @L["Edit"] diff --git a/Marechai/Pages/Admin/Details/Company.razor b/Marechai/Pages/Admin/Details/Company.razor new file mode 100644 index 00000000..6cb8df9f --- /dev/null +++ b/Marechai/Pages/Admin/Details/Company.razor @@ -0,0 +1,162 @@ +@{ +/****************************************************************************** +// 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/companies/details/{Id:int}" +@inherits OwningComponentBase +@inject IStringLocalizer L +@inject Iso31661NumericService CountriesService +@attribute [Authorize(Roles = "UberAdmin, Admin")] +

@L["Company details"]

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

@L["Loading..."]

+ + return; +} + +
+ + @L["Name"] + + + + @L["Status"] + + + @if(_editable || _model.Founded.HasValue) + { + + @L["Founded"] + + + } + @if (_editable || _model.Website != null) + { + + @L["Website"] + + + } + @if (_editable || _model.Twitter != null) + { + + @L["Twitter"] + + + } + @if (_editable || _model.Facebook != null) + { + + @L["Facebook"] + + + } + @if (_editable || _model.Address != null) + { + + @L["Address"] + + + } + @if (_editable || _model.City != null) + { + + @L["City"] + + + } + @if (_editable || _model.Province != null) + { + + @L["Province"] + + + } + @if (_editable || _model.PostalCode != null) + { + + @L["Postal code"] + + + } + @if (_editable) + { + + @L["Country"] + + + } + else if (_model.CountryId != null) + { + + @L["Country"] + + + } + @if (_editable || _model.Sold != null) + { + + @L["Sold"] + + + } + @if (_editable) + { + + @L["Sold to"] + + + } + else if (_model.SoldToId != null) + { + + @L["Sold to"] + + + } +
+
+ @L["Edit"] + @L["Back to list"] +
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Company.razor.cs b/Marechai/Pages/Admin/Details/Company.razor.cs new file mode 100644 index 00000000..fe020ead --- /dev/null +++ b/Marechai/Pages/Admin/Details/Company.razor.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Marechai.Database; +using Marechai.Database.Models; +using Marechai.ViewModels; +using Microsoft.AspNetCore.Components; + +namespace Marechai.Pages.Admin.Details +{ + public partial class Company + { + List _companies; + List _countries; + bool _editable; + bool _loaded; + Database.Models.Company _model; + [Parameter] + public int Id { get; set; } + + public string CompanyStatus + { + get => _model.Status.ToString(); + set + { + if(!Enum.TryParse(value, true, out CompanyStatus parsed)) + return; + + _model.Status = parsed; + } + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) + return; + + _loaded = true; + + if(Id <= 0) + return; + + _countries = await CountriesService.GetAsync(); + _companies = await Service.GetAsync(); + _model = await Service.GetAsync(Id); + + StateHasChanged(); + } + } +} \ No newline at end of file diff --git a/Marechai/Pages/Companies/View.razor.cs b/Marechai/Pages/Companies/View.razor.cs index 1fbdd767..b1b6f193 100644 --- a/Marechai/Pages/Companies/View.razor.cs +++ b/Marechai/Pages/Companies/View.razor.cs @@ -32,7 +32,7 @@ namespace Marechai.Pages.Companies return; } - _company = await Service.GetCompanyAsync(Id); + _company = await Service.GetAsync(Id); List machines = await Service.GetMachinesAsync(Id); _computers = machines.Where(m => m.Type == MachineType.Computer).ToList(); diff --git a/Marechai/Program.cs b/Marechai/Program.cs index 8629e994..a3c4c953 100644 --- a/Marechai/Program.cs +++ b/Marechai/Program.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // MARECHAI: Master repository of computing history artifacts information // ---------------------------------------------------------------------------- // @@ -114,7 +114,7 @@ namespace Marechai Console.WriteLine("\u001b[31;1mUpdating MySQL database without Entity Framework if it exists...\u001b[0m"); Database = new Mysql(); - bool res = Database.OpenDb("localhost", "marechai", "marechai", "marechaipass", 3306); + bool res = Database.OpenDb("zeus.claunia.com", "marechai", "marechai", "marechaipass", 3306); if(res) { diff --git a/Marechai/Resources/Services/CompaniesService.es.resx b/Marechai/Resources/Services/CompaniesService.es.resx index 0f351826..49237a79 100644 --- a/Marechai/Resources/Services/CompaniesService.es.resx +++ b/Marechai/Resources/Services/CompaniesService.es.resx @@ -290,4 +290,28 @@ Cancelar Cancel + + Detalles de compañía + Company details + + + Nombre + Name + + + Ciudad + City + + + Provincia + Province + + + Código postal + Postal code + + + Volver a la lista + Back to list + \ No newline at end of file diff --git a/Marechai/Services/CompaniesService.cs b/Marechai/Services/CompaniesService.cs index ccbdbd12..fc836c3b 100644 --- a/Marechai/Services/CompaniesService.cs +++ b/Marechai/Services/CompaniesService.cs @@ -62,7 +62,7 @@ namespace Marechai.Services Status = c.Status }).ToListAsync(); - public Task GetCompanyAsync(int id) => _context.Companies.FirstOrDefaultAsync(c => c.Id == id); + public Task GetAsync(int id) => _context.Companies.FirstOrDefaultAsync(c => c.Id == id); public async Task> GetMachinesAsync(int id) => await _context.Machines.Where(m => m.CompanyId == id).OrderBy(m => m.Name).Select(m => new Machine diff --git a/Marechai/Services/Iso31661NumericService.cs b/Marechai/Services/Iso31661NumericService.cs new file mode 100644 index 00000000..3e6905d4 --- /dev/null +++ b/Marechai/Services/Iso31661NumericService.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Marechai.Database.Models; +using Microsoft.EntityFrameworkCore; + +namespace Marechai.Services +{ + public class Iso31661NumericService + { + readonly MarechaiContext _context; + + public Iso31661NumericService(MarechaiContext context) => _context = context; + + public async Task> GetAsync() => + await _context.Iso31661Numeric.OrderBy(c => c.Name).ToListAsync(); + } +} \ No newline at end of file diff --git a/Marechai/Services/Register.cs b/Marechai/Services/Register.cs index ad051a62..e69c14ee 100644 --- a/Marechai/Services/Register.cs +++ b/Marechai/Services/Register.cs @@ -59,6 +59,7 @@ namespace Marechai.Services services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); } } } \ No newline at end of file diff --git a/Marechai/appsettings.json b/Marechai/appsettings.json index 2b2b42e5..553999af 100644 --- a/Marechai/appsettings.json +++ b/Marechai/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "server=localhost;port=3306;user=marechai;password=marechaipass;database=marechai;TreatTinyAsBoolean=false" + "DefaultConnection": "server=zeus.claunia.com;port=3306;user=marechai;password=marechaipass;database=marechai;TreatTinyAsBoolean=false" }, "Logging": { "LogLevel": { diff --git a/codealike.json b/codealike.json index 9d40673e..e9d938ec 100644 --- a/codealike.json +++ b/codealike.json @@ -1 +1 @@ -{"projectId":"fd3f3857-80b9-4ed7-90f8-c6ebd0ae449f","projectName":"Marechai"} \ No newline at end of file +{"projectId":"fd3f3857-80b9-4ed7-90f8-c6ebd0ae449f","projectName":"Marechai","neverTrack":false} \ No newline at end of file