mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Set display modes for companies admin.
This commit is contained in:
@@ -30,6 +30,9 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
@@ -49,6 +52,7 @@ namespace Cicm.Database.Models
|
||||
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
[DisplayFormat(DataFormatString = "{0:d}")]
|
||||
public DateTime? Founded { get; set; }
|
||||
public string Website { get; set; }
|
||||
public string Twitter { get; set; }
|
||||
@@ -63,6 +67,7 @@ namespace Cicm.Database.Models
|
||||
public CompanyStatus Status { get; set; }
|
||||
|
||||
public virtual Iso31661Numeric Country { get; set; }
|
||||
[DisplayName("Sold to")]
|
||||
public virtual Company SoldTo { get; set; }
|
||||
public virtual CompanyDescription Description { get; set; }
|
||||
public virtual ICollection<CompanyLogo> Logos { get; set; }
|
||||
@@ -74,5 +79,18 @@ namespace Cicm.Database.Models
|
||||
public virtual ICollection<SoundSynth> SoundSynths { get; set; }
|
||||
public virtual CompanyLogo LastLogo =>
|
||||
Logos?.OrderByDescending(l => l.Year).FirstOrDefault();
|
||||
|
||||
[DisplayName("Sold")]
|
||||
[NotMapped]
|
||||
public string SoldView =>
|
||||
Status != CompanyStatus.Active && Status != CompanyStatus.Unknown
|
||||
? Sold is null
|
||||
? "Unknown"
|
||||
: Sold.Value.ToShortDateString()
|
||||
: Sold is null
|
||||
? SoldToId is null
|
||||
? ""
|
||||
: "Unknown"
|
||||
: Sold.Value.ToShortDateString();
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
{
|
||||
IIncludableQueryable<Company, Company> cicmContext =
|
||||
_context.Companies.Include(c => c.Country).Include(c => c.SoldTo);
|
||||
return View(await cicmContext.ToListAsync());
|
||||
return View(await cicmContext.OrderBy(c => c.Name).ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Admin/Companies/Details/5
|
||||
|
||||
@@ -36,12 +36,15 @@
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h2>Index</h2>
|
||||
<h2>Companies</h2>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Create New</a>
|
||||
<a asp-action="Create"
|
||||
class="btn btn-primary">
|
||||
Create New
|
||||
</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@@ -57,7 +60,7 @@
|
||||
@Html.DisplayNameFor(model => model.Country)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Sold)
|
||||
@Html.DisplayNameFor(model => model.SoldView)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SoldTo)
|
||||
@@ -82,7 +85,7 @@
|
||||
@Html.DisplayFor(modelItem => item.Country.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sold)
|
||||
@Html.DisplayFor(modelItem => item.SoldView)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.SoldTo.Name)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.388</Version>
|
||||
<Version>3.0.99.392</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
Reference in New Issue
Block a user