mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Retrieve computer and console information from database for news controller.
This commit is contained in:
@@ -44,6 +44,8 @@ namespace cicm_web.Models
|
||||
public DateTime Date;
|
||||
/// <summary>URL of image</summary>
|
||||
public string Image;
|
||||
/// <summary>Subtext</summary>
|
||||
public string SubText;
|
||||
/// <summary>URL of target view, if applicable</summary>
|
||||
public string TargetView;
|
||||
/// <summary>Text</summary>
|
||||
@@ -69,9 +71,14 @@ namespace cicm_web.Models
|
||||
|
||||
static News TransformItem(Cicm.Database.Schemas.News dbItem)
|
||||
{
|
||||
string imageUrl;
|
||||
string text;
|
||||
string targetView;
|
||||
string imageUrl;
|
||||
string text;
|
||||
string targetView;
|
||||
string subtext;
|
||||
Computer computer;
|
||||
OwnComputer owncomputer;
|
||||
Console console;
|
||||
OwnConsole ownconsole;
|
||||
|
||||
switch(dbItem.Type)
|
||||
{
|
||||
@@ -79,46 +86,63 @@ namespace cicm_web.Models
|
||||
text = "New computer added to the database.";
|
||||
imageUrl = "assets/photos/computers/";
|
||||
targetView = "computer";
|
||||
computer = Computer.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{computer.Company.Name} - {computer.Model}";
|
||||
break;
|
||||
case NewsType.NewConsoleInDb:
|
||||
text = "New videoconsole added to the database.";
|
||||
imageUrl = "assets/photos/consoles/";
|
||||
targetView = "console";
|
||||
console = Console.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{console.Company.Name} - {console.Name}";
|
||||
break;
|
||||
case NewsType.NewComputerInCollection:
|
||||
text = "New computer added to the museum's collection.";
|
||||
imageUrl = "assets/photos/computers/";
|
||||
targetView = "collection_computer";
|
||||
text = "New computer added to the museum's collection.";
|
||||
imageUrl = "assets/photos/computers/";
|
||||
targetView = "collection_computer";
|
||||
owncomputer = OwnComputer.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{owncomputer.Computer.Company.Name} - {owncomputer.Computer.Model}";
|
||||
break;
|
||||
case NewsType.NewConsoleInCollection:
|
||||
text = "New videoconsole added to the museum's collection.";
|
||||
imageUrl = "assets/photos/consoles/";
|
||||
targetView = "collection_console";
|
||||
ownconsole = OwnConsole.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Name}";
|
||||
break;
|
||||
case NewsType.UpdatedComputerInDb:
|
||||
text = "Updated computer from the database.";
|
||||
imageUrl = "assets/photos/computers/";
|
||||
targetView = "computer";
|
||||
computer = Computer.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{computer.Company.Name} - {computer.Model}";
|
||||
break;
|
||||
case NewsType.UpdatedConsoleInDb:
|
||||
text = "Updated videoconsole from the database.";
|
||||
imageUrl = "assets/photos/consoles/";
|
||||
targetView = "console";
|
||||
console = Console.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{console.Company.Name} - {console.Name}";
|
||||
break;
|
||||
case NewsType.UpdatedComputerInCollection:
|
||||
text = "Updated computer from museum's collection.";
|
||||
imageUrl = "assets/photos/computers/";
|
||||
targetView = "collection_computer";
|
||||
text = "Updated computer from museum's collection.";
|
||||
imageUrl = "assets/photos/computers/";
|
||||
targetView = "collection_computer";
|
||||
owncomputer = OwnComputer.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{owncomputer.Computer.Company.Name} - {owncomputer.Computer.Model}";
|
||||
break;
|
||||
case NewsType.UpdatedConsoleInCollection:
|
||||
text = "Updated videoconsole from museum's collection.";
|
||||
imageUrl = "assets/photos/consoles/";
|
||||
targetView = "collection_console";
|
||||
ownconsole = OwnConsole.GetItem(dbItem.AffectedId);
|
||||
subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Name}";
|
||||
break;
|
||||
case NewsType.NewMoneyDonation:
|
||||
text = "New money donation.";
|
||||
imageUrl = null;
|
||||
targetView = null;
|
||||
subtext = null;
|
||||
break;
|
||||
default: throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
@@ -129,7 +153,8 @@ namespace cicm_web.Models
|
||||
Date = DateTime.ParseExact(dbItem.Date, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture),
|
||||
Image = imageUrl == null ? null : imageUrl + $"{dbItem.AffectedId}",
|
||||
Text = text,
|
||||
TargetView = targetView
|
||||
TargetView = targetView,
|
||||
SubText = subtext
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,8 +74,7 @@
|
||||
<a asp-action="View"
|
||||
asp-controller="@news.TargetView"
|
||||
asp-route-id="@news.AffectedId">
|
||||
<!-- TODO: Get this from models -->
|
||||
Company - Computer
|
||||
@news.SubText
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<Version>3.0.99.38</Version>
|
||||
<Version>3.0.99.41</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