@{ /****************************************************************************** // MARECHAI: Master repository of computing history artifacts information // ---------------------------------------------------------------------------- // // Filename : ByLetter.cshtml // Author(s) : Natalia Portillo // // --[ Description ] ---------------------------------------------------------- // // Lists computers by company // // --[ 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 "/company/{Id:int}" @using Marechai.Database.Models @using Marechai.Database @inherits OwningComponentBase @inject IStringLocalizer L @inject IWebHostEnvironment Host @if (!_loaded) {

@L["Loading..."]

return; } @if (_company is null) {

@L["Company not found."]

return; }

@if (_company.LastLogo != null && File.Exists(Path.Combine(Host.WebRootPath, "assets/logos", _company.LastLogo.Guid + ".svg"))) { }

@{ _carrouselActive = "active"; } @if (_company.Logos != null && _company.Logos.Count > 1) { // TODO: Carousel
}
@if (_company.Founded.HasValue) { } @switch (_company.Status) { case CompanyStatus.Unknown: break; case CompanyStatus.Active: break; case CompanyStatus.Sold: if (_company.Sold != null) { if (_soldTo != null) { } else { } } else { if (_soldTo != null) { } else { } } break; case CompanyStatus.Merged: if (_company.Sold != null) { if (_soldTo != null) { } else { } } else { if (_soldTo != null) { } else { } } break; case CompanyStatus.Bankrupt: if (_company.Sold != null) { } else { } break; case CompanyStatus.Defunct: if (_company.Sold != null) { } else { } break; case CompanyStatus.Renamed: if (_company.Sold != null) { if (_soldTo != null) { } else { } } else { if (_soldTo != null) { } else { } } break; default: throw new ArgumentOutOfRangeException(); } @if (!string.IsNullOrEmpty(_company.Website) || !string.IsNullOrEmpty(_company.Twitter) || !string.IsNullOrEmpty(_company.Facebook)) { }
@_company.Name
@L["Founded"] @_company.Founded.Value.ToLongDateString().
@L["Country"] @if (File.Exists(Path.Combine(Host.WebRootPath, "assets/flags/countries", _company.Country.Id + ".svg"))) { } @L[_company.Country.Name]
@L["Status"]@L["Current company status is unknown."]@L["Company is active."] @string.Format(L["Company sold to {0} on {1}."], _soldTo.Name, _company.Sold.Value.ToLongDateString()) @string.Format(L["Company sold on {0} to an unknown company."], _company.Sold.Value.ToLongDateString()) @string.Format(L["Company sold to {0} on an unknown date."], _soldTo.Name) @L["Company was sold to an unknown company on an unknown date."] @string.Format(L["Company merged on {0} to form {1}."], _company.Sold.Value.ToLongDateString(), _soldTo.Name) @string.Format(L["Company merged on {0} to form an unknown company."], _company.Sold.Value.ToLongDateString()) @string.Format(L["Company merged on an unknown date to form {0}."], _soldTo.Name) @L["Company merged to form an unknown company on an unknown date."]@string.Format(L["Company declared bankruptcy on {0}."], _company.Sold.Value.ToLongDateString())@L["Company declared bankruptcy on an unknown date."]@string.Format(L["Company ceased operations on {0}."], _company.Sold.Value.ToLongDateString())@L["Company ceased operations on an unknown date."] @string.Format(L["Company renamed to {0} on {1}."], _soldTo.Name, _company.Sold.Value.ToLongDateString()) @string.Format(L["Company was renamed on {0} to an unknown name."], _company.Sold.Value.ToLongDateString()) @string.Format(L["Company renamed to {0} on an unknown date."], _soldTo.Name) @L["Company renamed to an unknown name on an unknown date."]
@L["Address"] @_company.Address
@if (_company.City != _company.Province) { @_company.City
} @_company.PostalCode @_company.Province
@L["Links"] @if (!string.IsNullOrEmpty(_company.Website)) { @L["Website"]
} @if (!string.IsNullOrEmpty(_company.Twitter)) { Twitter
} @if (!string.IsNullOrEmpty(_company.Facebook)) { Facebook
}
@{ // TODO: Accordion }
@if (_computers.Count > 0) {
@foreach (var computer in _computers) { @computer.Name
}
} else {
} @if (_consoles.Count > 0) {
@foreach (var console in _consoles) { @console.Name
}
} else {
}
@if (_description != null) {
@((MarkupString)_description)
}
@code { [Parameter] public int Id { get; set; } bool _loaded; Company _company; string _carrouselActive; List _computers; List _consoles; string _description; Company _soldTo; public bool ComputersCollapsed { get; set; } = true; public bool ConsolesCollapsed { get; set; } = true; protected override async Task OnInitializedAsync() { if(Id <= 0) { _loaded = true; return; } _company = await Service.GetCompanyAsync(Id); var machines = await Service.GetMachinesAsync(Id); _computers = machines.Where(m => m.Type == MachineType.Computer).ToList(); _consoles = machines.Where(m => m.Type == MachineType.Console).ToList(); _description = await Service.GetDescriptionAsync(Id); _soldTo = await Service.GetSoldToAsync(_company.SoldToId); _loaded = true; } private void CollapseComputers() { if (_computers.Count == 0) return; ComputersCollapsed = !ComputersCollapsed; } private void CollapseConsoles() { if (_consoles.Count == 0) return; ConsolesCollapsed = !ConsolesCollapsed; } }