Add screens.

This commit is contained in:
2019-06-01 22:13:01 +01:00
parent 009b4d2e92
commit 43bbe7f720
10 changed files with 6029 additions and 2 deletions

View File

@@ -69,6 +69,7 @@ namespace Cicm.Database.Models
public virtual ICollection<SoundByMachine> Sound { get; set; }
public virtual ICollection<StorageByMachine> Storage { get; set; }
public virtual ICollection<MachinePhoto> Photos { get; set; }
public virtual ICollection<ScreensByMachine> Screens { get; set; }
[NotMapped]
[DisplayName("Introduced")]

View File

@@ -56,7 +56,9 @@ namespace Cicm.Database.Models
[DisplayName("Grayscale")]
public bool Grayscale { get; set; }
public virtual ICollection<ResolutionsByGpu> ResolutionsByGpu { get; set; }
public virtual ICollection<ResolutionsByGpu> ResolutionsByGpu { get; set; }
public virtual ICollection<ResolutionsByScreen> ResolutionsByScreen { get; set; }
public virtual ICollection<Screen> Screens { get; set; }
public long? PaletteView => Palette ?? Colors;

View File

@@ -0,0 +1,47 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : ResolutionsByGpu.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Junction of resolutions and gpus.
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/
using System.ComponentModel;
using Microsoft.AspNetCore.Mvc;
namespace Cicm.Database.Models
{
public class ResolutionsByScreen : BaseModel<long>
{
[Remote("VerifyUnique", "ResolutionsByScreen", "Admin", AdditionalFields = nameof(ResolutionId))]
public int ScreenId { get; set; }
[Remote("VerifyUnique", "ResolutionsByScreen", "Admin", AdditionalFields = nameof(ScreenId))]
public int ResolutionId { get; set; }
[DisplayName("GPU")]
public virtual Screen Screen { get; set; }
public virtual Resolution Resolution { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Cicm.Database.Models
{
public class Screen : BaseModel<int>
{
[Range(1, 131072)]
public double? Width { get; set; }
[Range(1, 131072)]
public double? Height { get; set; }
[Required]
public double Diagonal { get; set; }
[Required]
public virtual Resolution NativeResolution { get; set; }
[Range(2, 281474976710656)]
public long? EffectiveColors { get; set; }
[Required]
public string Type { get; set; }
[NotMapped]
public long? Colors => EffectiveColors ?? NativeResolution.Colors;
public virtual ICollection<ResolutionsByScreen> Resolutions { get; set; }
public virtual ICollection<ScreensByMachine> ScreensByMachines { get; set; }
}
}

View File

@@ -0,0 +1,47 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : ResolutionsByGpu.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Junction of resolutions and gpus.
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/
using System.ComponentModel;
using Microsoft.AspNetCore.Mvc;
namespace Cicm.Database.Models
{
public class ScreensByMachine : BaseModel<long>
{
[Remote("VerifyUnique", "ScreensByMachine", "Admin", AdditionalFields = nameof(MachineId))]
public int ScreenId { get; set; }
[Remote("VerifyUnique", "ScreensByMachine", "Admin", AdditionalFields = nameof(ScreenId))]
public int MachineId { get; set; }
[DisplayName("GPU")]
public virtual Screen Screen { get; set; }
public virtual Machine Machine { get; set; }
}
}

View File

@@ -73,6 +73,9 @@ namespace Cicm.Database.Models
public virtual DbSet<ProcessorsByOwnedMachine> ProcessorsByOwnedMachine { get; set; }
public virtual DbSet<SoundByOwnedMachine> SoundByOwnedMachine { get; set; }
public virtual DbSet<StorageByOwnedMachine> StorageByOwnedMachine { get; set; }
public virtual DbSet<Screen> Screens { get; set; }
public virtual DbSet<ScreensByMachine> ScreensByMachine { get; set; }
public virtual DbSet<ResolutionsByScreen> ResolutionsByScreen { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -950,6 +953,35 @@ namespace Cicm.Database.Models
.HasConstraintName("fk_resolutions_by_gpu_resolution");
});
modelBuilder.Entity<ResolutionsByScreen>(entity =>
{
entity.HasIndex(e => e.ScreenId);
entity.HasIndex(e => e.ResolutionId);
});
modelBuilder.Entity<ScreensByMachine>(entity =>
{
entity.HasIndex(e => e.ScreenId);
entity.HasIndex(e => e.MachineId);
});
modelBuilder.Entity<Screen>(entity =>
{
entity.HasIndex(e => e.Width);
entity.HasIndex(e => e.Height);
entity.HasIndex(e => e.Diagonal);
entity.HasIndex(e => e.EffectiveColors);
entity.HasIndex(e => e.Type);
entity.HasOne(d => d.NativeResolution).WithMany(p => p.Screens);
});
modelBuilder.Entity<SoundByMachine>(entity =>
{
entity.ToTable("sound_by_machine");