Add photos to database.

This commit is contained in:
2019-05-27 03:17:11 +01:00
parent 9a1e00cbee
commit c6f7a6be69
8 changed files with 4137 additions and 801 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,148 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class MachinePhotos : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>("Discriminator", "AspNetUsers", nullable: false, defaultValue: "");
migrationBuilder.CreateTable("MachinePhotos",
table => new
{
Id = table.Column<Guid>(),
Author = table.Column<string>(nullable: true),
CameraManufacturer = table.Column<string>(nullable: true),
CameraModel = table.Column<string>(nullable: true),
ColorSpace = table.Column<string>(nullable: true),
Comments = table.Column<string>(nullable: true),
Contrast = table.Column<string>(nullable: true),
CreationDate = table.Column<DateTime>(nullable: true),
DigitalZoomRatio = table.Column<double>(nullable: true),
ExifVersion = table.Column<string>(nullable: true),
Exposure = table.Column<double>(nullable: true),
ExposureMethod = table.Column<string>(nullable: true),
ExposureProgram = table.Column<string>(nullable: true),
Flash = table.Column<string>(nullable: true),
Focal = table.Column<int>(nullable: true),
FocalLength = table.Column<int>(nullable: true),
FocalLengthEquivalent = table.Column<string>(nullable: true),
HorizontalResolution = table.Column<int>(nullable: true),
IsoRating = table.Column<int>(nullable: true),
Lens = table.Column<string>(nullable: true),
License = table.Column<string>(nullable: true),
LightSource = table.Column<string>(nullable: true),
MeteringMode = table.Column<string>(nullable: true),
Orientation = table.Column<string>(nullable: true),
PixelComposition = table.Column<string>(nullable: true),
Saturation = table.Column<string>(nullable: true),
SceneCaptureType = table.Column<string>(nullable: true),
SceneControl = table.Column<string>(nullable: true),
SensingMethod = table.Column<string>(nullable: true),
Sharpness = table.Column<string>(nullable: true),
SoftwareUsed = table.Column<string>(nullable: true),
SubjectDistanceRange = table.Column<string>(nullable: true),
UploadDate =
table.Column<DateTime>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.ComputedColumn),
VerticalResolution = table.Column<int>(nullable: true),
WhiteBalance = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: true),
MachineId = table.Column<int>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_MachinePhotos", x => x.Id);
table.ForeignKey("FK_MachinePhotos_machines_MachineId", x => x.MachineId,
"machines", "id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_MachinePhotos_AspNetUsers_UserId", x => x.UserId,
"AspNetUsers", "Id", onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateIndex("IX_MachinePhotos_Author", "MachinePhotos", "Author");
migrationBuilder.CreateIndex("IX_MachinePhotos_CameraManufacturer", "MachinePhotos", "CameraManufacturer");
migrationBuilder.CreateIndex("IX_MachinePhotos_CameraModel", "MachinePhotos", "CameraModel");
migrationBuilder.CreateIndex("IX_MachinePhotos_ColorSpace", "MachinePhotos", "ColorSpace");
migrationBuilder.CreateIndex("IX_MachinePhotos_Comments", "MachinePhotos", "Comments");
migrationBuilder.CreateIndex("IX_MachinePhotos_Contrast", "MachinePhotos", "Contrast");
migrationBuilder.CreateIndex("IX_MachinePhotos_CreationDate", "MachinePhotos", "CreationDate");
migrationBuilder.CreateIndex("IX_MachinePhotos_DigitalZoomRatio", "MachinePhotos", "DigitalZoomRatio");
migrationBuilder.CreateIndex("IX_MachinePhotos_ExifVersion", "MachinePhotos", "ExifVersion");
migrationBuilder.CreateIndex("IX_MachinePhotos_Exposure", "MachinePhotos", "Exposure");
migrationBuilder.CreateIndex("IX_MachinePhotos_ExposureMethod", "MachinePhotos", "ExposureMethod");
migrationBuilder.CreateIndex("IX_MachinePhotos_ExposureProgram", "MachinePhotos", "ExposureProgram");
migrationBuilder.CreateIndex("IX_MachinePhotos_Flash", "MachinePhotos", "Flash");
migrationBuilder.CreateIndex("IX_MachinePhotos_Focal", "MachinePhotos", "Focal");
migrationBuilder.CreateIndex("IX_MachinePhotos_FocalLength", "MachinePhotos", "FocalLength");
migrationBuilder.CreateIndex("IX_MachinePhotos_FocalLengthEquivalent", "MachinePhotos",
"FocalLengthEquivalent");
migrationBuilder.CreateIndex("IX_MachinePhotos_HorizontalResolution", "MachinePhotos",
"HorizontalResolution");
migrationBuilder.CreateIndex("IX_MachinePhotos_IsoRating", "MachinePhotos", "IsoRating");
migrationBuilder.CreateIndex("IX_MachinePhotos_Lens", "MachinePhotos", "Lens");
migrationBuilder.CreateIndex("IX_MachinePhotos_License", "MachinePhotos", "License");
migrationBuilder.CreateIndex("IX_MachinePhotos_LightSource", "MachinePhotos", "LightSource");
migrationBuilder.CreateIndex("IX_MachinePhotos_MachineId", "MachinePhotos", "MachineId");
migrationBuilder.CreateIndex("IX_MachinePhotos_MeteringMode", "MachinePhotos", "MeteringMode");
migrationBuilder.CreateIndex("IX_MachinePhotos_Orientation", "MachinePhotos", "Orientation");
migrationBuilder.CreateIndex("IX_MachinePhotos_PixelComposition", "MachinePhotos", "PixelComposition");
migrationBuilder.CreateIndex("IX_MachinePhotos_Saturation", "MachinePhotos", "Saturation");
migrationBuilder.CreateIndex("IX_MachinePhotos_SceneCaptureType", "MachinePhotos", "SceneCaptureType");
migrationBuilder.CreateIndex("IX_MachinePhotos_SceneControl", "MachinePhotos", "SceneControl");
migrationBuilder.CreateIndex("IX_MachinePhotos_SensingMethod", "MachinePhotos", "SensingMethod");
migrationBuilder.CreateIndex("IX_MachinePhotos_Sharpness", "MachinePhotos", "Sharpness");
migrationBuilder.CreateIndex("IX_MachinePhotos_SoftwareUsed", "MachinePhotos", "SoftwareUsed");
migrationBuilder.CreateIndex("IX_MachinePhotos_SubjectDistanceRange", "MachinePhotos",
"SubjectDistanceRange");
migrationBuilder.CreateIndex("IX_MachinePhotos_UploadDate", "MachinePhotos", "UploadDate");
migrationBuilder.CreateIndex("IX_MachinePhotos_UserId", "MachinePhotos", "UserId");
migrationBuilder.CreateIndex("IX_MachinePhotos_VerticalResolution", "MachinePhotos", "VerticalResolution");
migrationBuilder.CreateIndex("IX_MachinePhotos_WhiteBalance", "MachinePhotos", "WhiteBalance");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("MachinePhotos");
migrationBuilder.DropColumn("Discriminator", "AspNetUsers");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,10 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Identity;
namespace Cicm.Database.Models
{
public class ApplicationUser : IdentityUser { }
public class ApplicationUser : IdentityUser
{
public virtual ICollection<MachinePhoto> Photos { get; set; }
}
}

View File

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

View File

@@ -0,0 +1,74 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace Cicm.Database.Models
{
public class MachinePhoto : BaseModel<Guid>
{
public string Author { get; set; }
[DisplayName("Camera manufacturer")]
public string CameraManufacturer { get; set; }
[DisplayName("Camera model")]
public string CameraModel { get; set; }
[DisplayName("Color space")]
public string ColorSpace { get; set; }
[DisplayName("User comments")]
public string Comments { get; set; }
public string Contrast { get; set; }
[DisplayName("Date and time of digitizing")]
public DateTime? CreationDate { get; set; }
[DisplayName("Digital zoom ratio")]
public double? DigitalZoomRatio { get; set; }
[DisplayName("Exif version")]
public string ExifVersion { get; set; }
[DisplayName("Exposure time")]
public double? Exposure { get; set; }
[DisplayName("Exposure mode")]
public string ExposureMethod { get; set; }
[DisplayName("Exposure Program")]
public string ExposureProgram { get; set; }
public string Flash { get; set; }
[DisplayName("F-number")]
public int? Focal { get; set; }
[DisplayName("Lens focal length")]
public int? FocalLength { get; set; }
[DisplayName("Focal length in 35 mm film")]
public string FocalLengthEquivalent { get; set; }
[DisplayName("Horizontal resolution")]
public int? HorizontalResolution { get; set; }
[DisplayName("ISO speed rating")]
public int? IsoRating { get; set; }
[DisplayName("Lens used")]
public string Lens { get; set; }
public string License { get; set; }
[DisplayName("Light source")]
public string LightSource { get; set; }
[DisplayName("Metering mode")]
public string MeteringMode { get; set; }
public string Orientation { get; set; }
[DisplayName("Pixel composition")]
public string PixelComposition { get; set; }
public string Saturation { get; set; }
[DisplayName("Scene capture type")]
public string SceneCaptureType { get; set; }
[DisplayName("Scene control")]
public string SceneControl { get; set; }
[DisplayName("Sensing method")]
public string SensingMethod { get; set; }
public string Sharpness { get; set; }
[DisplayName("Software used")]
public string SoftwareUsed { get; set; }
[DisplayName("Subject distance range")]
public string SubjectDistanceRange { get; set; }
[Timestamp]
public DateTime UploadDate { get; set; }
[DisplayName("Vertical resolution")]
public int? VerticalResolution { get; set; }
[DisplayName("White balance")]
public string WhiteBalance { get; set; }
public virtual ApplicationUser User { get; set; }
public virtual Machine Machine { get; set; }
}
}

View File

@@ -54,6 +54,7 @@ namespace Cicm.Database.Models
public virtual DbSet<Log> Log { get; set; }
public virtual DbSet<MachineFamily> MachineFamilies { get; set; }
public virtual DbSet<Machine> Machines { get; set; }
public virtual DbSet<MachinePhoto> MachinePhotos { get; set; }
public virtual DbSet<MemoryByMachine> MemoryByMachine { get; set; }
public virtual DbSet<MoneyDonation> MoneyDonations { get; set; }
public virtual DbSet<News> News { get; set; }
@@ -479,6 +480,81 @@ namespace Cicm.Database.Models
.HasConstraintName("fk_machines_family");
});
modelBuilder.Entity<MachinePhoto>(entity =>
{
entity.HasIndex(e => e.Author);
entity.HasIndex(e => e.CameraManufacturer);
entity.HasIndex(e => e.CameraModel);
entity.HasIndex(e => e.ColorSpace);
entity.HasIndex(e => e.Comments);
entity.HasIndex(e => e.Contrast);
entity.HasIndex(e => e.CreationDate);
entity.HasIndex(e => e.DigitalZoomRatio);
entity.HasIndex(e => e.ExifVersion);
entity.HasIndex(e => e.Exposure);
entity.HasIndex(e => e.ExposureMethod);
entity.HasIndex(e => e.ExposureProgram);
entity.HasIndex(e => e.Flash);
entity.HasIndex(e => e.Focal);
entity.HasIndex(e => e.FocalLength);
entity.HasIndex(e => e.FocalLengthEquivalent);
entity.HasIndex(e => e.HorizontalResolution);
entity.HasIndex(e => e.IsoRating);
entity.HasIndex(e => e.Lens);
entity.HasIndex(e => e.License);
entity.HasIndex(e => e.LightSource);
entity.HasIndex(e => e.MeteringMode);
entity.HasIndex(e => e.Orientation);
entity.HasIndex(e => e.PixelComposition);
entity.HasIndex(e => e.Saturation);
entity.HasIndex(e => e.SceneCaptureType);
entity.HasIndex(e => e.SceneControl);
entity.HasIndex(e => e.SensingMethod);
entity.HasIndex(e => e.Sharpness);
entity.HasIndex(e => e.SoftwareUsed);
entity.HasIndex(e => e.SubjectDistanceRange);
entity.HasIndex(e => e.UploadDate);
entity.HasIndex(e => e.VerticalResolution);
entity.HasIndex(e => e.WhiteBalance);
entity.HasOne(d => d.Machine).WithMany(p => p.Photos).OnDelete(DeleteBehavior.Cascade);
entity.HasOne(d => d.User).WithMany(p => p.Photos).OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity<MemoryByMachine>(entity =>
{
entity.ToTable("memory_by_machine");

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Version>3.0.99.576</Version>
<Version>3.0.99.577</Version>
<Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product>