diff --git a/cicm_web/Models/Company.cs b/cicm_web/Models/Company.cs index 12617d8e..3032160f 100644 --- a/cicm_web/Models/Company.cs +++ b/cicm_web/Models/Company.cs @@ -31,15 +31,28 @@ using System; using System.Collections.Generic; using System.Linq; +using Cicm.Database.Schemas; namespace cicm_web.Models { public class CompanyWithItems { - public ComputerMini[] Computers; - public ConsoleMini[] Consoles; - public int Id; - public string Name; + public string Address; + public string City; + public ComputerMini[] Computers; + public ConsoleMini[] Consoles; + public Iso3166 Country; + public string Facebook; + public DateTime Founded; + public int Id; + public string Name; + public string PostalCode; + public string Province; + public DateTime Sold; + public Cicm.Database.Schemas.Company SoldTo; + public CompanyStatus Status; + public string Twitter; + public string Website; public static CompanyWithItems GetItem(int id) { @@ -49,10 +62,22 @@ namespace cicm_web.Models ? null : new CompanyWithItems { - Name = dbItem.Name, - Id = dbItem.Id, - Computers = ComputerMini.GetItemsWithCompany(id, dbItem.Name), - Consoles = ConsoleMini.GetItemsWithCompany(id, dbItem.Name) + Name = dbItem.Name, + Id = dbItem.Id, + Computers = ComputerMini.GetItemsWithCompany(id, dbItem.Name), + Consoles = ConsoleMini.GetItemsWithCompany(id, dbItem.Name), + Address = dbItem.Address, + City = dbItem.City, + Country = dbItem.Country, + Facebook = dbItem.Facebook, + Founded = dbItem.Founded, + PostalCode = dbItem.PostalCode, + Province = dbItem.Province, + Sold = dbItem.Sold, + SoldTo = dbItem.SoldTo, + Status = dbItem.Status, + Twitter = dbItem.Twitter, + Website = dbItem.Website }; } @@ -62,7 +87,25 @@ namespace cicm_web.Models bool? result = Program.Database?.Operations.GetCompanies(out dbItems); if(result == null || result.Value == false || dbItems == null) return null; - return dbItems.Select(t => new CompanyWithItems {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray(); + return dbItems.Select(t => new CompanyWithItems + { + Id = t.Id, + Name = t.Name, + Computers = ComputerMini.GetItemsWithCompany(t.Id, t.Name), + Consoles = ConsoleMini.GetItemsWithCompany(t.Id, t.Name), + Address = t.Address, + City = t.City, + Country = t.Country, + Facebook = t.Facebook, + Founded = t.Founded, + PostalCode = t.PostalCode, + Province = t.Province, + Sold = t.Sold, + SoldTo = t.SoldTo, + Status = t.Status, + Twitter = t.Twitter, + Website = t.Website + }).OrderBy(t => t.Name).ToArray(); } public static CompanyWithItems[] GetItemsStartingWithLetter(char letter) @@ -73,7 +116,25 @@ namespace cicm_web.Models return dbItems .Where(t => t.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase)) - .Select(t => new CompanyWithItems {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray(); + .Select(t => new CompanyWithItems + { + Id = t.Id, + Name = t.Name, + Computers = ComputerMini.GetItemsWithCompany(t.Id, t.Name), + Consoles = ConsoleMini.GetItemsWithCompany(t.Id, t.Name), + Address = t.Address, + City = t.City, + Country = t.Country, + Facebook = t.Facebook, + Founded = t.Founded, + PostalCode = t.PostalCode, + Province = t.Province, + Sold = t.Sold, + SoldTo = t.SoldTo, + Status = t.Status, + Twitter = t.Twitter, + Website = t.Website + }).OrderBy(t => t.Name).ToArray(); } } diff --git a/cicm_web/Views/Company/View.cshtml b/cicm_web/Views/Company/View.cshtml index a8e84996..64aec302 100644 --- a/cicm_web/Views/Company/View.cshtml +++ b/cicm_web/Views/Company/View.cshtml @@ -32,36 +32,231 @@ ViewData["Title"] = "Companies"; } @using System.IO +@using Cicm.Database.Schemas @model CompanyWithItems -

Search results:

-

- @if(Model != null) - { - if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".gif"))) +@if(Model != null) +{ +

+ @if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".gif"))) { } - if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".jpg"))) + @if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".jpg"))) { } - if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".png"))) + @if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".png"))) { } - @Model.Name -
+

+
+ + + + + @if(Model.Founded > DateTime.MinValue) + { + + + + + } + + + + + + + @switch(Model.Status) + { + case CompanyStatus.Unknown: + + break; + case CompanyStatus.Active: + + break; + case CompanyStatus.Sold: + if(Model.Sold != DateTime.MinValue) + { + if(Model.SoldTo != null) + { + + } + else + { + + } + } + else + { + if(Model.SoldTo != null) + { + + } + else + { + + } + } + break; + case CompanyStatus.Merged: + if(Model.Sold != DateTime.MinValue) + { + if(Model.SoldTo != null) + { + + } + else + { + + } + } + else + { + if(Model.SoldTo != null) + { + + } + else + { + + } + } + break; + case CompanyStatus.Bankrupt: + if(Model.Sold != DateTime.MinValue) + { + + } + else + { + + } + break; + case CompanyStatus.Defunct: + if(Model.Sold != DateTime.MinValue) + { + + } + else + { + + } + break; + case CompanyStatus.Renamed: + if(Model.Sold != DateTime.MinValue) + { + if(Model.SoldTo != null) + { + + } + else + { + + } + } + else + { + if(Model.SoldTo != null) + { + + } + else + { + + } + } + break; + default: + throw new ArgumentOutOfRangeException(); + } + + + + + + @if(!string.IsNullOrEmpty(Model.Website) || !string.IsNullOrEmpty(Model.Twitter) || !string.IsNullOrEmpty(Model.Facebook)) + { + + + + + } +
+ @Model.Name +
Founded@Model.Founded.ToLongDateString().
Country@Model.Country.Name
StatusCurrent company status is unknown.Company is active. + Company was sold to + + @Model.SoldTo.Name on @Model.Sold.ToLongDateString(). + Company was sold on @Model.Sold.ToLongDateString() to an unknown company. + Company was sold to + + @Model.SoldTo.Name on an unknown date. + Company was sold to an unknown company on an unknown date. + Company was merged on @Model.Sold.ToLongDateString() to form + + @Model.SoldTo.Name. + Company was merge on @Model.Sold.ToLongDateString() to form an unknown company. + Company was merged on an unknown date to form + + @Model.SoldTo.Name. + Company was merged to form an unknown company on an unknown date.Company declared bankruptcy on @Model.Sold.ToLongDateString().Company declared bankruptcy on an unknown date.Company ceased operations on @Model.Sold.ToLongDateString().Company ceased operations on an unknown date. + Company was renamed to + + @Model.SoldTo.Name on @Model.Sold.ToLongDateString(). + Company was renamed on @Model.Sold.ToLongDateString() to an unknown name. + Company was renamed to + + @Model.SoldTo.Name on an unknown date. + Company was renamed to an unknown name on an unknown date.
Address + @Model.Address
+ @if(Model.City != Model.Province) + { + @Model.City
+ } + @Model.PostalCode @Model.Province
Links + @if(!string.IsNullOrEmpty(Model.Website)) + { + Website +
+ } + @if(!string.IsNullOrEmpty(Model.Twitter)) + { + Twitter +
+ } + @if(!string.IsNullOrEmpty(Model.Facebook)) + { + Facebook +
+ } +
+
- if(Model.Computers.Any()) +
+ @if(Model.Computers.Any()) {

- @Model.Computers.Count() computers found in the database.
+ @Model.Computers.Count() computers made by this company found in the database.
@foreach(ComputerMini computer in Model.Computers) { There are no computers found in the database that belong to that company.

+

There are no computers made by this company in the database.

} +
- if(Model.Consoles.Any()) +
+ @if(Model.Consoles.Any()) {

- @Model.Consoles.Count() videoconsoles found in the database.
+ @Model.Consoles.Count() videogame consoles made by this company found in the database.
@foreach(ConsoleMini console in Model.Consoles) {
There are no videoconsoles found in the database that belong to that company.

+

There are no videogame consoles made by this company found in the database.

} - } - else - { -

Company not found!

- } -

\ No newline at end of file +
+} +else +{ +

Company not found!

+} + diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index 5d2f6db9..f8280c15 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.0 - 3.0.99.121 + 3.0.99.123 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website