Add source URL to machine photos.

This commit is contained in:
2019-05-29 01:00:27 +01:00
parent 785892decb
commit bb931e7209
11 changed files with 5464 additions and 6 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class AddMachinePhotoSourceUrl : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>("Source", "MachinePhotos", nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn("Source", "MachinePhotos");
}
}
}

View File

@@ -3772,6 +3772,8 @@ namespace Cicm.Database.Migrations
b.Property<string>("SoftwareUsed"); b.Property<string>("SoftwareUsed");
b.Property<string>("Source");
b.Property<ushort?>("SubjectDistanceRange"); b.Property<ushort?>("SubjectDistanceRange");
b.Property<DateTime>("UploadDate").IsConcurrencyToken().ValueGeneratedOnAddOrUpdate(); b.Property<DateTime>("UploadDate").IsConcurrencyToken().ValueGeneratedOnAddOrUpdate();

View File

@@ -64,6 +64,8 @@ namespace Cicm.Database.Models
public double? VerticalResolution { get; set; } public double? VerticalResolution { get; set; }
[DisplayName("White balance")] [DisplayName("White balance")]
public WhiteBalance? WhiteBalance { get; set; } public WhiteBalance? WhiteBalance { get; set; }
[Url]
public string Source { get; set; }
public virtual ApplicationUser User { get; set; } public virtual ApplicationUser User { get; set; }
public virtual Machine Machine { get; set; } public virtual Machine Machine { get; set; }

View File

@@ -104,7 +104,8 @@ namespace cicm_web.Areas.Admin.Controllers
UploadUser = m.User.UserName, UploadUser = m.User.UserName,
Machine = Machine =
$"{m.Machine.Company.Name} {m.Machine.Name}", $"{m.Machine.Company.Name} {m.Machine.Name}",
MachineId = m.Machine.Id MachineId = m.Machine.Id,
Source = m.Source
}).FirstOrDefaultAsync(m => m.Id == id); }).FirstOrDefaultAsync(m => m.Id == id);
if(machinePhoto == null) return NotFound(); if(machinePhoto == null) return NotFound();
@@ -128,7 +129,8 @@ namespace cicm_web.Areas.Admin.Controllers
// more details see http://go.microsoft.com/fwlink/?LinkId=317598. // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost] [HttpPost]
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("MachineId,LicenseId,Photo")] MachinePhotoViewModel machinePhoto) public async Task<IActionResult> Create([Bind("MachineId,LicenseId,Photo,Source")]
MachinePhotoViewModel machinePhoto)
{ {
if(!ModelState.IsValid) return View(machinePhoto); if(!ModelState.IsValid) return View(machinePhoto);
@@ -395,7 +397,7 @@ namespace cicm_web.Areas.Admin.Controllers
[HttpPost] [HttpPost]
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(Guid id, [Bind( public async Task<IActionResult> Edit(Guid id, [Bind(
"Author,CameraManufacturer,CameraModel,ColorSpace,Comments,Contrast,CreationDate,DigitalZoomRatio,ExifVersion,Exposure,ExposureMethod,ExposureProgram,Flash,Focal,FocalLength,FocalLengthEquivalent,HorizontalResolution,IsoRating,Lens,LicenseId,LightSource,MachineId,MeteringMode,ResolutionUnit,Orientation,Saturation,SceneCaptureType,SensingMethod,Sharpness,SoftwareUsed,SubjectDistanceRange,VerticalResolution,WhiteBalance,Id")] "Author,CameraManufacturer,CameraModel,ColorSpace,Comments,Contrast,CreationDate,DigitalZoomRatio,ExifVersion,Exposure,ExposureMethod,ExposureProgram,Flash,Focal,FocalLength,FocalLengthEquivalent,HorizontalResolution,IsoRating,Lens,LicenseId,LightSource,MachineId,MeteringMode,ResolutionUnit,Orientation,Saturation,SceneCaptureType,SensingMethod,Sharpness,SoftwareUsed,SubjectDistanceRange,VerticalResolution,WhiteBalance,Id,Source")]
MachinePhoto machinePhoto) MachinePhoto machinePhoto)
{ {
if(id != machinePhoto.Id) return NotFound(); if(id != machinePhoto.Id) return NotFound();

View File

@@ -71,5 +71,6 @@ namespace cicm_web.Areas.Admin.Models
public string UploadUser { get; set; } public string UploadUser { get; set; }
public string Machine { get; set; } public string Machine { get; set; }
public int MachineId { get; set; } public int MachineId { get; set; }
public string Source { get; set; }
} }
} }

View File

@@ -22,5 +22,7 @@ namespace cicm_web.Areas.Admin.Models
public int MachineId { get; set; } public int MachineId { get; set; }
public int LicenseId { get; set; } public int LicenseId { get; set; }
public string ErrorMessage { get; set; } public string ErrorMessage { get; set; }
[Url]
public string Source { get; set; }
} }
} }

View File

@@ -71,6 +71,13 @@
class="text-danger"> class="text-danger">
</span> </span>
</div> </div>
<div class="form-group">
<label asp-for="Source"
class="control-label">
</label>
<input asp-for="Source"
class="form-control" />
</div>
<div class="form-group"> <div class="form-group">
<label asp-for="Photo" <label asp-for="Photo"
class="control-label"> class="control-label">

View File

@@ -32,10 +32,23 @@
@Html.DisplayNameFor(model => model.Machine) @Html.DisplayNameFor(model => model.Machine)
</dt> </dt>
<dd class="col-sm-10"> <dd class="col-sm-10">
<a asp-area="" asp-controller="Machine" asp-route-id="@Model.MachineId" asp-action="View" target="_blank"> <a asp-area=""
asp-controller="Machine"
asp-route-id="@Model.MachineId"
asp-action="View"
target="_blank">
@Html.DisplayFor(model => model.Machine) @Html.DisplayFor(model => model.Machine)
</a> </a>
</dd> </dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Source)
</dt>
<dd class="col-sm-10">
@if(Model.Source != null)
{
<a hred="@Html.DisplayFor(model => model.Source)">Link</a>
}
</dd>
<dd class="col-sm-10"> <dd class="col-sm-10">
<img src="/assets/photos/machines/@(Model.Id).jpg" /> <img src="/assets/photos/machines/@(Model.Id).jpg" />
</dd> </dd>

View File

@@ -355,6 +355,16 @@
class="text-danger"> class="text-danger">
</span> </span>
</div> </div>
<div class="form-group">
<label asp-for="Source"
class="control-label">
</label>
<input asp-for="Source"
class="form-control" />
<span asp-validation-for="Source"
class="text-danger">
</span>
</div>
<div class="form-group"> <div class="form-group">
<label asp-for="SubjectDistanceRange" <label asp-for="SubjectDistanceRange"
class="control-label"> class="control-label">

View File

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