Set defaults for booleans.

This commit is contained in:
2020-06-01 03:20:35 +01:00
parent 448c836d4d
commit e95ee921f6
19 changed files with 4148 additions and 90 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Marechai.Database.Migrations
{
public partial class SetDetaulfsForBooleans : Migration
{
protected override void Up(MigrationBuilder migrationBuilder) { }
protected override void Down(MigrationBuilder migrationBuilder) { }
}
}

View File

@@ -40,23 +40,27 @@ namespace Marechai.Database.Models
public string Os { get; set; } public string Os { get; set; }
[Required, StringLength(8)] [Required, StringLength(8)]
public string Platform { get; set; } public string Platform { get; set; }
[DisplayName("GIF87")] [DisplayName("GIF87"), DefaultValue(false)]
public bool Gif87 { get; set; } public bool Gif87 { get; set; }
[DisplayName("GIF89")] [DisplayName("GIF89"), DefaultValue(false)]
public bool Gif89 { get; set; } public bool Gif89 { get; set; }
[DisplayName("JPEG")] [DisplayName("JPEG"), DefaultValue(false)]
public bool Jpeg { get; set; } public bool Jpeg { get; set; }
[DisplayName("PNG")] [DisplayName("PNG"), DefaultValue(false)]
public bool Png { get; set; } public bool Png { get; set; }
[DisplayName("Transparent PNG")] [DisplayName("Transparent PNG"), DefaultValue(false)]
public bool Pngt { get; set; } public bool Pngt { get; set; }
[DisplayName("Animated GIF")] [DisplayName("Animated GIF"), DefaultValue(false)]
public bool Agif { get; set; } public bool Agif { get; set; }
[DefaultValue(false)]
public bool Table { get; set; } public bool Table { get; set; }
[DefaultValue(false)]
public bool Colors { get; set; } public bool Colors { get; set; }
[DisplayName("JavaScript")] [DisplayName("JavaScript"), DefaultValue(false)]
public bool Js { get; set; } public bool Js { get; set; }
[DefaultValue(false)]
public bool Frames { get; set; } public bool Frames { get; set; }
[DefaultValue(false)]
public bool Flash { get; set; } public bool Flash { get; set; }
} }
} }

View File

@@ -27,7 +27,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
namespace Marechai.Database.Models namespace Marechai.Database.Models
@@ -85,19 +84,5 @@ namespace Marechai.Database.Models
public virtual ICollection<PeopleByCompany> People { get; set; } public virtual ICollection<PeopleByCompany> People { get; set; }
public virtual CompanyLogo LastLogo => Logos?.OrderByDescending(l => l.Year).FirstOrDefault(); public virtual CompanyLogo LastLogo => Logos?.OrderByDescending(l => l.Year).FirstOrDefault();
public virtual DocumentCompany DocumentCompany { get; set; } public virtual DocumentCompany DocumentCompany { get; set; }
[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();
[NotMapped]
public CompanyDescription Description => Descriptions?.FirstOrDefault();
} }
} }

View File

@@ -24,10 +24,7 @@
*******************************************************************************/ *******************************************************************************/
using System; using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.AspNetCore.Http;
namespace Marechai.Database.Models namespace Marechai.Database.Models
{ {
@@ -39,11 +36,5 @@ namespace Marechai.Database.Models
public Guid Guid { get; set; } public Guid Guid { get; set; }
public virtual Company Company { get; set; } public virtual Company Company { get; set; }
[NotMapped, Required(ErrorMessage = "SVG logo required"), DisplayName("Upload SVG logo:")]
public IFormFile SvgLogo { get; set; }
[NotMapped]
public string ErrorMessage { get; set; }
} }
} }

View File

@@ -23,6 +23,7 @@
// Copyright © 2003-2020 Natalia Portillo // Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/ *******************************************************************************/
using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@@ -33,6 +34,7 @@ namespace Marechai.Database.Models
[Column(TypeName = "char(3)"), Key, Required] [Column(TypeName = "char(3)"), Key, Required]
public string Id { get; set; } public string Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
[DefaultValue(false)]
public bool Enabled { get; set; } public bool Enabled { get; set; }
} }
} }

View File

@@ -27,7 +27,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Marechai.Database.Models namespace Marechai.Database.Models
{ {
@@ -60,8 +59,5 @@ namespace Marechai.Database.Models
public virtual Company Company { get; set; } public virtual Company Company { get; set; }
public virtual ICollection<GpusByMachine> GpusByMachine { get; set; } public virtual ICollection<GpusByMachine> GpusByMachine { get; set; }
public virtual ICollection<ResolutionsByGpu> ResolutionsByGpu { get; set; } public virtual ICollection<ResolutionsByGpu> ResolutionsByGpu { get; set; }
[NotMapped]
public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown";
} }
} }

View File

@@ -36,9 +36,9 @@ namespace Marechai.Database.Models
public string Name { get; set; } public string Name { get; set; }
[DisplayName("SPDX identifier")] [DisplayName("SPDX identifier")]
public string SPDX { get; set; } public string SPDX { get; set; }
[DisplayName("FSF approved"), Required] [DisplayName("FSF approved"), Required, DefaultValue(false)]
public bool FsfApproved { get; set; } public bool FsfApproved { get; set; }
[DisplayName("OSI approved"), Required] [DisplayName("OSI approved"), Required, DefaultValue(false)]
public bool OsiApproved { get; set; } public bool OsiApproved { get; set; }
[DisplayName("License text link"), StringLength(512), Url] [DisplayName("License text link"), StringLength(512), Url]
public string Link { get; set; } public string Link { get; set; }

View File

@@ -25,9 +25,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Marechai.Database.Models namespace Marechai.Database.Models
{ {
@@ -66,9 +64,5 @@ namespace Marechai.Database.Models
public virtual ICollection<DocumentsByMachine> Documents { get; set; } public virtual ICollection<DocumentsByMachine> Documents { get; set; }
public virtual ICollection<BooksByMachine> Books { get; set; } public virtual ICollection<BooksByMachine> Books { get; set; }
public virtual ICollection<MagazinesByMachine> Magazines { get; set; } public virtual ICollection<MagazinesByMachine> Magazines { get; set; }
[NotMapped, DisplayName("Introduced")]
public string IntroducedView =>
Introduced == DateTime.MinValue ? "Prototype" : Introduced?.ToShortDateString() ?? "Unknown";
} }
} }

View File

@@ -38,15 +38,15 @@ namespace Marechai.Database.Models
public StatusType Status { get; set; } public StatusType Status { get; set; }
[DisplayName("Last status check date")] [DisplayName("Last status check date")]
public DateTime? LastStatusDate { get; set; } public DateTime? LastStatusDate { get; set; }
[DisplayName("Available for trade or sale")] [DisplayName("Available for trade or sale"), DefaultValue(false)]
public bool Trade { get; set; } public bool Trade { get; set; }
[DisplayName("Has original boxes")] [DisplayName("Has original boxes"), DefaultValue(false)]
public bool Boxed { get; set; } public bool Boxed { get; set; }
[DisplayName("Has original manuals")] [DisplayName("Has original manuals"), DefaultValue(false)]
public bool Manuals { get; set; } public bool Manuals { get; set; }
[DisplayName("Serial number")] [DisplayName("Serial number")]
public string SerialNumber { get; set; } public string SerialNumber { get; set; }
[DisplayName("Serial number visible to other users")] [DisplayName("Serial number visible to other users"), DefaultValue(false)]
public bool SerialNumberVisible { get; set; } public bool SerialNumberVisible { get; set; }
public int MachineId { get; set; } public int MachineId { get; set; }
public string UserId { get; set; } public string UserId { get; set; }

View File

@@ -24,6 +24,7 @@
*******************************************************************************/ *******************************************************************************/
using System; using System;
using System.ComponentModel;
namespace Marechai.Database.Models namespace Marechai.Database.Models
{ {
@@ -34,6 +35,7 @@ namespace Marechai.Database.Models
public string Position { get; set; } public string Position { get; set; }
public DateTime? Start { get; set; } public DateTime? Start { get; set; }
public DateTime? End { get; set; } public DateTime? End { get; set; }
[DefaultValue(false)]
public bool Ongoing { get; set; } public bool Ongoing { get; set; }
public virtual Person Person { get; set; } public virtual Person Person { get; set; }

View File

@@ -54,7 +54,6 @@ namespace Marechai.Database.Models
public string Alias { get; set; } public string Alias { get; set; }
[DisplayName("Name to be displayed")] [DisplayName("Name to be displayed")]
public string DisplayName { get; set; } public string DisplayName { get; set; }
[NotMapped, DisplayName("Name")] [NotMapped, DisplayName("Name")]
public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}"; public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}";

View File

@@ -28,7 +28,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Marechai.Database.Models namespace Marechai.Database.Models
{ {
@@ -93,8 +92,5 @@ namespace Marechai.Database.Models
public virtual InstructionSet InstructionSet { get; set; } public virtual InstructionSet InstructionSet { get; set; }
public virtual ICollection<InstructionSetExtensionsByProcessor> InstructionSetExtensions { get; set; } public virtual ICollection<InstructionSetExtensionsByProcessor> InstructionSetExtensions { get; set; }
public virtual ICollection<ProcessorsByMachine> ProcessorsByMachine { get; set; } public virtual ICollection<ProcessorsByMachine> ProcessorsByMachine { get; set; }
[NotMapped]
public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown";
} }
} }

View File

@@ -41,9 +41,9 @@ namespace Marechai.Database.Models
public long? Colors { get; set; } public long? Colors { get; set; }
[Range(2, 281474976710656)] [Range(2, 281474976710656)]
public long? Palette { get; set; } public long? Palette { get; set; }
[DisplayName("Character based")] [DisplayName("Character based"), DefaultValue(false)]
public bool Chars { get; set; } public bool Chars { get; set; }
[DisplayName("Grayscale")] [DisplayName("Grayscale"), DefaultValue(false)]
public bool Grayscale { get; set; } public bool Grayscale { get; set; }
public virtual ICollection<ResolutionsByGpu> ResolutionsByGpu { get; set; } public virtual ICollection<ResolutionsByGpu> ResolutionsByGpu { get; set; }

View File

@@ -26,7 +26,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Marechai.Database.Models namespace Marechai.Database.Models
{ {
@@ -45,22 +44,6 @@ namespace Marechai.Database.Models
[Required] [Required]
public string Type { get; set; } public string Type { get; set; }
[NotMapped]
public long? Colors => EffectiveColors ?? NativeResolution.Colors;
[NotMapped]
public string Size
{
get
{
if(Width != null &&
Height != null)
return$"{Width}x{Height} mm";
return"Unknown";
}
}
public virtual ICollection<ResolutionsByScreen> Resolutions { get; set; } public virtual ICollection<ResolutionsByScreen> Resolutions { get; set; }
public virtual ICollection<ScreensByMachine> ScreensByMachines { get; set; } public virtual ICollection<ScreensByMachine> ScreensByMachines { get; set; }
[Required] [Required]

View File

@@ -27,7 +27,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Marechai.Database.Models namespace Marechai.Database.Models
{ {
@@ -56,8 +55,5 @@ namespace Marechai.Database.Models
public virtual Company Company { get; set; } public virtual Company Company { get; set; }
public virtual ICollection<SoundByMachine> SoundByMachine { get; set; } public virtual ICollection<SoundByMachine> SoundByMachine { get; set; }
[NotMapped]
public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown";
} }
} }

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<Version>3.0.99.1551</Version> <Version>3.0.99.1556</Version>
<Company>Canary Islands Computer Museum</Company> <Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright> <Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product> <Product>Canary Islands Computer Museum Website</Product>

View File

@@ -23,8 +23,6 @@
// Copyright © 2003-2020 Natalia Portillo // Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/ *******************************************************************************/
using System.ComponentModel.DataAnnotations.Schema;
namespace Marechai.ViewModels namespace Marechai.ViewModels
{ {
public class ScreenViewModel : BaseViewModel<int> public class ScreenViewModel : BaseViewModel<int>
@@ -37,10 +35,8 @@ namespace Marechai.ViewModels
public long? EffectiveColors { get; set; } public long? EffectiveColors { get; set; }
public string Type { get; set; } public string Type { get; set; }
[NotMapped]
public long? Colors => EffectiveColors ?? NativeResolution.Colors; public long? Colors => EffectiveColors ?? NativeResolution.Colors;
[NotMapped]
public string Size public string Size
{ {
get get

View File

@@ -24,7 +24,6 @@
*******************************************************************************/ *******************************************************************************/
using System; using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Marechai.ViewModels namespace Marechai.ViewModels
{ {
@@ -42,7 +41,6 @@ namespace Marechai.ViewModels
public int? WhiteNoise { get; set; } public int? WhiteNoise { get; set; }
public int? Type { get; set; } public int? Type { get; set; }
[NotMapped]
public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown"; public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown";
} }
} }