Audit all changes made in the admin view.

This commit is contained in:
2020-06-10 00:27:39 +01:00
parent c6941d1450
commit e111dc5e32
89 changed files with 516 additions and 236 deletions

View File

@@ -23,8 +23,11 @@
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.Extensions.Configuration;
namespace Marechai.Database.Models
@@ -92,8 +95,7 @@ namespace Marechai.Database.Models
public virtual DbSet<SoundSynth> SoundSynths { get; set; }
public virtual DbSet<StorageByMachine> StorageByMachine { get; set; }
public virtual DbSet<StorageByOwnedMachine> StorageByOwnedMachine { get; set; }
public virtual DbSet<Audit> Audit { get; set; }
public virtual DbSet<Audit> Audit { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -105,6 +107,85 @@ namespace Marechai.Database.Models
optionsBuilder.UseMySql(configuration.GetConnectionString("DefaultConnection")).UseLazyLoadingProxies();
}
public async Task<int> SaveChangesWithUserAsync(string userId)
{
ChangeTracker.DetectChanges();
List<Audit> audits = new List<Audit>();
foreach(EntityEntry entry in ChangeTracker.Entries())
{
if(entry.Entity is Audit ||
entry.State == EntityState.Detached ||
entry.State == EntityState.Unchanged)
continue;
var audit = new Audit();
audit.UserId = userId;
audit.Table = entry.Metadata.GetTableName();
Dictionary<string, object> keys = new Dictionary<string, object>();
Dictionary<string, object> olds = new Dictionary<string, object>();
Dictionary<string, object> news = new Dictionary<string, object>();
List<string> columns = new List<string>();
foreach(PropertyEntry property in entry.Properties)
{
string propertyName = property.Metadata.Name;
string columnName = property.Metadata.GetColumnName();
if(property.Metadata.IsPrimaryKey())
{
keys[propertyName] = property.CurrentValue;
continue;
}
switch(entry.State)
{
case EntityState.Deleted:
audit.Type = AuditType.Deleted;
olds[propertyName] = property.CurrentValue;
break;
case EntityState.Modified:
if(property.IsModified)
{
audit.Type = AuditType.Updated;
news[propertyName] = property.CurrentValue;
olds[propertyName] = property.OriginalValue;
columns.Add(columnName);
}
break;
case EntityState.Added:
audit.Type = AuditType.Created;
news[propertyName] = property.CurrentValue;
break;
}
}
if(keys.Count > 0)
audit.Keys = keys;
if(olds.Count > 0)
audit.OldValues = olds;
if(news.Count > 0)
audit.NewValues = news;
if(columns.Count > 0)
audit.AffectedColumns = columns;
audits.Add(audit);
}
await Audit.AddRangeAsync(audits);
return await SaveChangesAsync();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
@@ -1468,7 +1549,6 @@ namespace Marechai.Database.Models
modelBuilder.Entity<Audit>(entity =>
{
entity.HasIndex(d => d.UserId);
entity.HasIndex(d => d.Table);
entity.HasIndex(d => d.Type);
});

View File

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

View File

@@ -26,9 +26,11 @@
}
@page "/admin/companies"
@using Marechai.Database.Models
@inherits OwningComponentBase<CompaniesService>
@inject IStringLocalizer<CompaniesService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Companies"]</h3>
@if (_companies is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -56,11 +57,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_companies = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_currentCompany.Id);
await Service.DeleteAsync(_currentCompany.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_companies = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -29,6 +29,7 @@
@page "/admin/companies/edit/{Id:int}"
@page "/admin/companies/create"
@using Marechai.Database
@using Marechai.Database.Models
@inherits OwningComponentBase<CompaniesService>
@inject IStringLocalizer<CompaniesService> L
@inject Iso31661NumericService CountriesService
@@ -37,6 +38,8 @@
@inject IWebHostEnvironment Host
@inject IFileReaderService FileReaderService;
@inject IJSRuntime JSRuntime
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]

View File

@@ -38,6 +38,7 @@ using Marechai.Shared;
using Marechai.ViewModels;
using Markdig;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.JSInterop;
using SkiaSharp;
using Svg.Skia;
@@ -48,6 +49,7 @@ namespace Marechai.Pages.Admin.Details
{
const int _maxUploadSize = 5 * 1048576;
bool _addingDescription;
AuthenticationState _authState;
List<CompanyViewModel> _companies;
List<Iso31661Numeric> _countries;
bool _creating;
@@ -118,6 +120,7 @@ namespace Marechai.Pages.Admin.Details
_logos = await CompanyLogosService.GetByCompany(Id);
_description = await Service.GetDescriptionAsync(Id);
_selectedDescriptionTab = "markdown";
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/companies/edit/",
@@ -246,9 +249,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;
@@ -325,7 +328,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await CompanyLogosService.DeleteAsync(_currentLogo.Id);
await CompanyLogosService.DeleteAsync(_currentLogo.Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_logos = await CompanyLogosService.GetByCompany(Id);
_deleteInProgress = false;
@@ -360,7 +365,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await CompanyLogosService.ChangeYearAsync(_currentLogo.Id, _unknownLogoYear ? null : _currentLogoYear);
await CompanyLogosService.ChangeYearAsync(_currentLogo.Id, _unknownLogoYear ? null : _currentLogoYear,
(await UserManager.GetUserAsync(_authState.User)).Id);
_logos = await CompanyLogosService.GetByCompany(Id);
_yearChangeInProgress = false;
@@ -589,7 +596,8 @@ namespace Marechai.Pages.Admin.Details
return;
}
await CompanyLogosService.CreateAsync(Id, guid, _unknownLogoYear ? null : _currentLogoYear);
await CompanyLogosService.CreateAsync(Id, guid, _unknownLogoYear ? null : _currentLogoYear,
(await UserManager.GetUserAsync(_authState.User)).Id);
_logos = await CompanyLogosService.GetByCompany(Id);
@@ -652,7 +660,9 @@ namespace Marechai.Pages.Admin.Details
_description.Html = Markdown.ToHtml(_description.Markdown, _pipeline);
await Service.CreateOrUpdateDescriptionAsync(Id, _description);
await Service.CreateOrUpdateDescriptionAsync(Id, _description,
(await UserManager.GetUserAsync(_authState.User)).Id);
_addingDescription = false;
await CancelDescription();
}

View File

@@ -617,7 +617,7 @@ namespace Marechai.Pages.Admin.Details
{
try
{
await Service.CreateAsync(_model);
await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_addToDatabase = true;
}
catch(Exception e)

View File

@@ -28,10 +28,13 @@
@page "/admin/document_companies/details/{Id:int}"
@page "/admin/document_companies/edit/{Id:int}"
@page "/admin/document_companies/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<DocumentCompaniesService>
@inject IStringLocalizer<DocumentCompaniesService> L
@inject CompaniesService CompaniesService
@inject NavigationManager NavigationManager
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Document company details"]</h3>
<hr />

View File

@@ -30,11 +30,13 @@ using Blazorise;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
public partial class DocumentCompany
{
AuthenticationState _authState;
List<CompanyViewModel> _companies;
bool _creating;
bool _editing;
@@ -63,6 +65,7 @@ namespace Marechai.Pages.Admin.Details
_companies = await CompaniesService.GetAsync();
_model = _creating ? new DocumentCompanyViewModel() : await Service.GetAsync(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/document_companies/edit/",
@@ -116,9 +119,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;

View File

@@ -28,10 +28,13 @@
@page "/admin/document_people/details/{Id:int}"
@page "/admin/document_people/edit/{Id:int}"
@page "/admin/document_people/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<DocumentPeopleService>
@inject IStringLocalizer<DocumentPeopleService> L
@inject PeopleService PeopleService
@inject NavigationManager NavigationManager
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Document person details"]</h3>
<hr />

View File

@@ -30,11 +30,13 @@ using Blazorise;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
public partial class DocumentPerson
{
AuthenticationState _authState;
bool _creating;
bool _editing;
bool _loaded;
@@ -63,8 +65,9 @@ namespace Marechai.Pages.Admin.Details
!_creating)
return;
_people = await PeopleService.GetAsync();
_model = _creating ? new DocumentPersonViewModel() : await Service.GetAsync(Id);
_people = await PeopleService.GetAsync();
_model = _creating ? new DocumentPersonViewModel() : await Service.GetAsync(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/document_people/edit/",
@@ -152,9 +155,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;

View File

@@ -28,12 +28,15 @@
@page "/admin/gpus/details/{Id:int}"
@page "/admin/gpus/edit/{Id:int}"
@page "/admin/gpus/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<GpusService>
@inject IStringLocalizer<GpusService> L
@inject CompaniesService CompaniesService
@inject NavigationManager NavigationManager
@inject ResolutionsService ResolutionsService
@inject ResolutionsByGpuService ResolutionsByGpuService
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Graphical processing unit details"]</h3>
<hr />

View File

@@ -31,6 +31,7 @@ using Blazorise;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
@@ -38,6 +39,7 @@ namespace Marechai.Pages.Admin.Details
{
bool _addingResolution;
int? _addingResolutionId;
AuthenticationState _authState;
List<CompanyViewModel> _companies;
bool _creating;
ResolutionByGpuViewModel _currentResolution;
@@ -81,6 +83,7 @@ namespace Marechai.Pages.Admin.Details
_model = _creating ? new GpuViewModel() : await Service.GetAsync(Id);
_resolutions = await ResolutionsService.GetAsync();
_gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/gpus/edit/", StringComparison.InvariantCulture);
@@ -172,9 +175,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;
@@ -225,7 +228,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await ResolutionsByGpuService.DeleteAsync(_currentResolution.Id);
await ResolutionsByGpuService.DeleteAsync(_currentResolution.Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id);
_deleteInProgress = false;
@@ -273,7 +278,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await ResolutionsByGpuService.CreateAsync(_addingResolutionId.Value, Id);
await ResolutionsByGpuService.CreateAsync(_addingResolutionId.Value, Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id);
_addingResolution = false;

View File

@@ -28,10 +28,13 @@
@page "/admin/instruction_sets/details/{Id:int}"
@page "/admin/instruction_sets/edit/{Id:int}"
@page "/admin/instruction_sets/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<InstructionSetsService>
@inject IStringLocalizer<InstructionSetsService> L
@attribute [Authorize(Roles = "UberAdmin, Admin")]
@inject NavigationManager NavigationManager
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
<h3>@L["Instruction set details"]</h3>
<hr />

View File

@@ -28,11 +28,13 @@ using System.Threading.Tasks;
using Blazorise;
using Marechai.Shared;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
public partial class InstructionSet
{
AuthenticationState _authState;
bool _creating;
bool _editing;
bool _loaded;
@@ -55,7 +57,8 @@ namespace Marechai.Pages.Admin.Details
!_creating)
return;
_model = _creating ? new Database.Models.InstructionSet() : await Service.GetAsync(Id);
_model = _creating ? new Database.Models.InstructionSet() : await Service.GetAsync(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/instruction_sets/edit/",
@@ -93,9 +96,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;

View File

@@ -28,10 +28,13 @@
@page "/admin/instruction_set_extensions/details/{Id:int}"
@page "/admin/instruction_set_extensions/edit/{Id:int}"
@page "/admin/instruction_set_extensions/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<InstructionSetExtensionsService>
@inject IStringLocalizer<InstructionSetExtensionsService> L
@attribute [Authorize(Roles = "UberAdmin, Admin")]
@inject NavigationManager NavigationManager
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
<h3>@L["Instruction set extension details"]</h3>
<hr />

View File

@@ -28,11 +28,13 @@ using System.Threading.Tasks;
using Blazorise;
using Marechai.Shared;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
public partial class InstructionSetExtension
{
AuthenticationState _authState;
bool _creating;
bool _editing;
bool _loaded;
@@ -55,7 +57,8 @@ namespace Marechai.Pages.Admin.Details
!_creating)
return;
_model = _creating ? new Database.Models.InstructionSetExtension() : await Service.GetAsync(Id);
_model = _creating ? new Database.Models.InstructionSetExtension() : await Service.GetAsync(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/instruction_set_extensions/edit/",
@@ -93,9 +96,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;

View File

@@ -28,9 +28,12 @@
@page "/admin/licenses/details/{Id:int}"
@page "/admin/licenses/edit/{Id:int}"
@page "/admin/licenses/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<LicensesService>
@inject IStringLocalizer<LicensesService> L
@inject NavigationManager NavigationManager
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["License details"]</h3>
<hr />

View File

@@ -28,11 +28,13 @@ using System.Threading.Tasks;
using Blazorise;
using Marechai.Shared;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
public partial class License
{
AuthenticationState _authState;
bool _creating;
bool _editing;
bool _loaded;
@@ -56,7 +58,8 @@ namespace Marechai.Pages.Admin.Details
!_creating)
return;
_model = _creating ? new Database.Models.License() : await Service.GetAsync(Id);
_model = _creating ? new Database.Models.License() : await Service.GetAsync(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/licenses/edit/",
@@ -119,9 +122,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;

View File

@@ -29,6 +29,7 @@
@page "/admin/machines/edit/{Id:int}"
@page "/admin/machines/create"
@using Marechai.Database
@using Marechai.Database.Models
@inherits OwningComponentBase<MachinesService>
@inject IStringLocalizer<MachinesService> L
@inject CompaniesService CompaniesService
@@ -45,6 +46,8 @@
@inject ScreensByMachineService ScreensByMachineService
@inject ScreensService ScreensService
@inject MachinePhotosService MachinePhotosService
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Machine details"]</h3>
<hr />

View File

@@ -32,6 +32,7 @@ using Marechai.Database;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
@@ -55,6 +56,7 @@ namespace Marechai.Pages.Admin.Details
int _addingStorageInterface;
long? _addingStorageSize;
int _addingStorageType;
AuthenticationState _authState;
List<CompanyViewModel> _companies;
List<ProcessorViewModel> _cpus;
bool _creating;
@@ -138,6 +140,7 @@ namespace Marechai.Pages.Admin.Details
_machineStorage = await StorageByMachineService.GetByMachine(Id);
_machineScreens = await ScreensByMachineService.GetByMachine(Id);
_photos = await MachinePhotosService.GetGuidsByMachineAsync(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/machines/edit/",
@@ -200,9 +203,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;
@@ -260,7 +263,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await GpusByMachineService.DeleteAsync(_currentGpuByMachine.Id);
await GpusByMachineService.DeleteAsync(_currentGpuByMachine.Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineGpus = await GpusByMachineService.GetByMachine(Id);
_deleteInProgress = false;
@@ -317,7 +322,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await GpusByMachineService.CreateAsync(_addingGpuId.Value, Id);
await GpusByMachineService.CreateAsync(_addingGpuId.Value, Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineGpus = await GpusByMachineService.GetByMachine(Id);
_addingGpu = false;
@@ -354,7 +361,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await SoundSynthsByMachineService.DeleteAsync(_currentSoundByMachine.Id);
await SoundSynthsByMachineService.DeleteAsync(_currentSoundByMachine.Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineSound = await SoundSynthsByMachineService.GetByMachine(Id);
_deleteInProgress = false;
@@ -396,7 +405,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await SoundSynthsByMachineService.CreateAsync(_addingSoundId.Value, Id);
await SoundSynthsByMachineService.CreateAsync(_addingSoundId.Value, Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineSound = await SoundSynthsByMachineService.GetByMachine(Id);
_addingSound = false;
@@ -436,7 +447,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await ProcessorsByMachineService.DeleteAsync(_currentCpuByMachine.Id);
await ProcessorsByMachineService.DeleteAsync(_currentCpuByMachine.Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineCpus = await ProcessorsByMachineService.GetByMachine(Id);
_deleteInProgress = false;
@@ -481,7 +494,8 @@ namespace Marechai.Pages.Admin.Details
await Task.Yield();
await ProcessorsByMachineService.CreateAsync(_addingCpuId.Value, Id,
_unknownProcessorSpeed ? null : _addingProcessorSpeed);
_unknownProcessorSpeed ? null : _addingProcessorSpeed,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineCpus = await ProcessorsByMachineService.GetByMachine(Id);
@@ -531,7 +545,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await MemoriesByMachineService.DeleteAsync(_currentMemoryByMachine.Id);
await MemoriesByMachineService.DeleteAsync(_currentMemoryByMachine.Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineMemories = await MemoriesByMachineService.GetByMachine(Id);
_deleteInProgress = false;
@@ -572,7 +588,8 @@ namespace Marechai.Pages.Admin.Details
await MemoriesByMachineService.CreateAsync(Id, (MemoryType)_addingMemoryType,
(MemoryUsage)_addingMemoryUsage,
_unknownMemorySize ? null : _addingMemorySize,
_unknownMemorySpeed ? null : _addingMemorySpeed);
_unknownMemorySpeed ? null : _addingMemorySpeed,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineMemories = await MemoriesByMachineService.GetByMachine(Id);
@@ -633,7 +650,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await StorageByMachineService.DeleteAsync(_currentStorageByMachine.Id);
await StorageByMachineService.DeleteAsync(_currentStorageByMachine.Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineStorage = await StorageByMachineService.GetByMachine(Id);
_deleteInProgress = false;
@@ -671,7 +690,8 @@ namespace Marechai.Pages.Admin.Details
await StorageByMachineService.CreateAsync(Id, (StorageType)_addingStorageType,
(StorageInterface)_addingStorageInterface,
_unknownStorageSize ? null : _addingStorageSize);
_unknownStorageSize ? null : _addingStorageSize,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineStorage = await StorageByMachineService.GetByMachine(Id);
@@ -717,7 +737,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await ScreensByMachineService.DeleteAsync(_currentScreenByMachine.Id);
await ScreensByMachineService.DeleteAsync(_currentScreenByMachine.Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineScreens = await ScreensByMachineService.GetByMachine(Id);
_deleteInProgress = false;
@@ -759,7 +781,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await ScreensByMachineService.CreateAsync(_addingScreenId.Value, Id);
await ScreensByMachineService.CreateAsync(_addingScreenId.Value, Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_machineScreens = await ScreensByMachineService.GetByMachine(Id);
_addingScreen = false;

View File

@@ -28,10 +28,13 @@
@page "/admin/machine_families/details/{Id:int}"
@page "/admin/machine_families/edit/{Id:int}"
@page "/admin/machine_families/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<MachineFamiliesService>
@inject IStringLocalizer<MachineFamiliesService> L
@inject CompaniesService CompaniesService
@inject NavigationManager NavigationManager
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Machine family details"]</h3>
<hr />

View File

@@ -30,11 +30,13 @@ using Blazorise;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
public partial class MachineFamily
{
AuthenticationState _authState;
List<CompanyViewModel> _companies;
bool _creating;
bool _editing;
@@ -60,6 +62,7 @@ namespace Marechai.Pages.Admin.Details
_companies = await CompaniesService.GetAsync();
_model = _creating ? new MachineFamilyViewModel() : await Service.GetAsync(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/machine_families/edit/",
@@ -96,9 +99,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;

View File

@@ -34,7 +34,7 @@
@inject NavigationManager NavigationManager
@inject LicensesService LicensesService
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Machine photo details"]</h3>
<hr />

View File

@@ -32,6 +32,7 @@ using Marechai.Database.Models;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Orientation = Marechai.Database.Orientation;
namespace Marechai.Pages.Admin.Details
@@ -39,6 +40,7 @@ namespace Marechai.Pages.Admin.Details
public partial class MachinePhoto
{
const int _maxUploadSize = 25 * 1048576;
AuthenticationState _authState;
bool _editing;
List<Database.Models.License> _licenses;
bool _loaded;
@@ -272,8 +274,9 @@ namespace Marechai.Pages.Admin.Details
if(Id == Guid.Empty)
return;
_model = await Service.GetAsync(Id);
_licenses = await LicensesService.GetAsync();
_model = await Service.GetAsync(Id);
_licenses = await LicensesService.GetAsync();
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/machines/photo/edit/", StringComparison.InvariantCulture);
@@ -341,7 +344,7 @@ namespace Marechai.Pages.Admin.Details
async void OnSaveClicked()
{
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_model = await Service.GetAsync(Id);
SetCheckboxes();

View File

@@ -28,10 +28,13 @@
@page "/admin/people/details/{Id:int}"
@page "/admin/people/edit/{Id:int}"
@page "/admin/people/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<PeopleService>
@inject IStringLocalizer<PeopleService> L
@inject Iso31661NumericService CountriesService
@inject NavigationManager NavigationManager
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Person details"]</h3>
<hr />

View File

@@ -31,11 +31,13 @@ using Marechai.Database.Models;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
public partial class Person
{
AuthenticationState _authState;
List<Iso31661Numeric> _countries;
bool _creating;
bool _editing;
@@ -69,6 +71,7 @@ namespace Marechai.Pages.Admin.Details
_countries = await CountriesService.GetAsync();
_model = _creating ? new PersonViewModel() : await Service.GetAsync(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/people/edit/",
@@ -185,9 +188,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;

View File

@@ -28,6 +28,7 @@
@page "/admin/processors/details/{Id:int}"
@page "/admin/processors/edit/{Id:int}"
@page "/admin/processors/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<ProcessorsService>
@inject IStringLocalizer<ProcessorsService> L
@inject CompaniesService CompaniesService
@@ -35,6 +36,8 @@
@inject NavigationManager NavigationManager
@inject InstructionSetExtensionsByProcessorService InstructionSetExtensionsByProcessorService
@inject InstructionSetExtensionsService InstructionSetExtensionsService
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Processor details"]</h3>
<hr />

View File

@@ -31,27 +31,27 @@ using Blazorise;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
public partial class Processor
{
bool _addingExtension;
int? _addingExtensionId;
List<CompanyViewModel> _companies;
bool _creating;
InstructionSetExtensionByProcessorViewModel _currentInstructionByMachine;
bool _deleteInProgress;
string _deleteText;
string _deleteTitle;
bool _editing;
Modal _frmDelete;
List<Database.Models.InstructionSetExtension> _instructionSetExtensions;
List<Database.Models.InstructionSet> _instructionSets;
bool _loaded;
ProcessorViewModel _model;
bool _addingExtension;
int? _addingExtensionId;
AuthenticationState _authState;
List<CompanyViewModel> _companies;
bool _creating;
InstructionSetExtensionByProcessorViewModel _currentInstructionByMachine;
bool _deleteInProgress;
string _deleteText;
string _deleteTitle;
bool _editing;
Modal _frmDelete;
List<Database.Models.InstructionSetExtension> _instructionSetExtensions;
List<Database.Models.InstructionSet> _instructionSets;
bool _loaded;
ProcessorViewModel _model;
List<InstructionSetExtensionByProcessorViewModel> _processorExtensions;
bool _prototype;
bool _savingExtension;
@@ -101,6 +101,7 @@ namespace Marechai.Pages.Admin.Details
_model = _creating ? new ProcessorViewModel() : await Service.GetAsync(Id);
_instructionSetExtensions = await InstructionSetExtensionsService.GetAsync();
_processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/processors/edit/",
@@ -289,9 +290,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;
@@ -350,7 +351,10 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await InstructionSetExtensionsByProcessorService.DeleteAsync(_currentInstructionByMachine.Id);
await InstructionSetExtensionsByProcessorService.DeleteAsync(_currentInstructionByMachine.Id,
(await UserManager.
GetUserAsync(_authState.User)).Id);
_processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id);
_deleteInProgress = false;
@@ -398,7 +402,10 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await InstructionSetExtensionsByProcessorService.CreateAsync(Id, _addingExtensionId.Value);
await InstructionSetExtensionsByProcessorService.CreateAsync(Id, _addingExtensionId.Value,
(await UserManager.
GetUserAsync(_authState.User)).Id);
_processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id);
_addingExtension = false;

View File

@@ -28,9 +28,12 @@
@page "/admin/resolutions/details/{Id:int}"
@page "/admin/resolutions/edit/{Id:int}"
@page "/admin/resolutions/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<ResolutionsService>
@inject IStringLocalizer<ResolutionsService> L
@inject NavigationManager NavigationManager
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Resolution details"]</h3>
<hr />

View File

@@ -29,11 +29,13 @@ using Blazorise;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
public partial class Resolution
{
AuthenticationState _authState;
bool _creating;
bool _editing;
bool _loaded;
@@ -57,7 +59,8 @@ namespace Marechai.Pages.Admin.Details
!_creating)
return;
_model = _creating ? new ResolutionViewModel() : await Service.GetAsync(Id);
_model = _creating ? new ResolutionViewModel() : await Service.GetAsync(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/resolutions/edit/",
@@ -111,9 +114,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;

View File

@@ -28,12 +28,14 @@
@page "/admin/screens/details/{Id:int}"
@page "/admin/screens/edit/{Id:int}"
@page "/admin/screens/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<ScreensService>
@inject IStringLocalizer<ScreensService> L
@inject ResolutionsService ResolutionsService
@inject NavigationManager NavigationManager
@inject ResolutionsByScreenService ResolutionsByScreenService
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Screen details"]</h3>
<hr />

View File

@@ -31,6 +31,7 @@ using Blazorise;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
@@ -38,6 +39,7 @@ namespace Marechai.Pages.Admin.Details
{
bool _addingResolution;
int? _addingResolutionId;
AuthenticationState _authState;
bool _creating;
ResolutionByScreenViewModel _currentResolution;
bool _deleteInProgress;
@@ -74,6 +76,7 @@ namespace Marechai.Pages.Admin.Details
_resolutions = await ResolutionsService.GetAsync();
_model = _creating ? new ScreenViewModel() : await Service.GetAsync(Id);
_screenResolutions = await ResolutionsByScreenService.GetByScreen(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/screens/edit/",
@@ -139,9 +142,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;
@@ -180,7 +183,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await ResolutionsByScreenService.DeleteAsync(_currentResolution.Id);
await ResolutionsByScreenService.DeleteAsync(_currentResolution.Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_screenResolutions = await ResolutionsByScreenService.GetByScreen(Id);
_deleteInProgress = false;
@@ -228,7 +233,9 @@ namespace Marechai.Pages.Admin.Details
// Yield thread to let UI to update
await Task.Yield();
await ResolutionsByScreenService.CreateAsync(_addingResolutionId.Value, Id);
await ResolutionsByScreenService.CreateAsync(_addingResolutionId.Value, Id,
(await UserManager.GetUserAsync(_authState.User)).Id);
_screenResolutions = await ResolutionsByScreenService.GetByScreen(Id);
_addingResolution = false;

View File

@@ -28,10 +28,13 @@
@page "/admin/sound_synths/details/{Id:int}"
@page "/admin/sound_synths/edit/{Id:int}"
@page "/admin/sound_synths/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<SoundSynthsService>
@inject IStringLocalizer<SoundSynthsService> L
@inject CompaniesService CompaniesService
@inject NavigationManager NavigationManager
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Sound synthesizer details"]</h3>
<hr />

View File

@@ -30,11 +30,13 @@ using Blazorise;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin.Details
{
public partial class SoundSynth
{
AuthenticationState _authState;
List<CompanyViewModel> _companies;
bool _creating;
bool _editing;
@@ -69,6 +71,7 @@ namespace Marechai.Pages.Admin.Details
_companies = await CompaniesService.GetAsync();
_model = _creating ? new SoundSynthViewModel() : await Service.GetAsync(Id);
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/sound_synths/edit/",
@@ -167,9 +170,9 @@ namespace Marechai.Pages.Admin.Details
return;
if(_creating)
Id = await Service.CreateAsync(_model);
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
else
await Service.UpdateAsync(_model);
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
_editing = false;
_creating = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/document_companies"
@using Marechai.Database.Models
@inherits OwningComponentBase<DocumentCompaniesService>
@inject IStringLocalizer<DocumentCompaniesService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Document companies"]</h3>
@if (_companies is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -56,11 +57,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_companies = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_currentCompany.Id);
await Service.DeleteAsync(_currentCompany.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_companies = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/document_people"
@using Marechai.Database.Models
@inherits OwningComponentBase<DocumentPeopleService>
@inject IStringLocalizer<DocumentPeopleService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Document companies"]</h3>
@if (_people is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_people = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_person.Id);
await Service.DeleteAsync(_person.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_people = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/gpus"
@using Marechai.Database.Models
@inherits OwningComponentBase<GpusService>
@inject IStringLocalizer<GpusService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Graphics Processing Units"]</h3>
@if (_gpus is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_gpus = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_gpu.Id);
await Service.DeleteAsync(_gpu.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_gpus = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/instruction_set_extensions"
@using Marechai.Database.Models
@inherits OwningComponentBase<InstructionSetExtensionsService>
@inject IStringLocalizer<InstructionSetExtensionsService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Instruction set extensions"]</h3>
@if (_extensions is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_extensions = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_extension.Id);
await Service.DeleteAsync(_extension.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_extensions = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/instruction_sets"
@using Marechai.Database.Models
@inherits OwningComponentBase<InstructionSetsService>
@inject IStringLocalizer<InstructionSetsService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Instruction sets"]</h3>
@if (_instructionSets is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_instructionSets = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_instructionSet.Id);
await Service.DeleteAsync(_instructionSet.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_instructionSets = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/licenses"
@using Marechai.Database.Models
@inherits OwningComponentBase<LicensesService>
@inject IStringLocalizer<LicensesService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Licenses"]</h3>
@if (_licenses is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_licenses = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_license.Id);
await Service.DeleteAsync(_license.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_licenses = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/machine_families"
@using Marechai.Database.Models
@inherits OwningComponentBase<MachineFamiliesService>
@inject IStringLocalizer<MachineFamiliesService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Machine families"]</h3>
@if (_machineFamilies is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_machineFamilies = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_machineFamily.Id);
await Service.DeleteAsync(_machineFamily.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_machineFamilies = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/machines"
@using Marechai.Database.Models
@inherits OwningComponentBase<MachinesService>
@inject IStringLocalizer<MachinesService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Machines"]</h3>
@if (_machines is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_machines = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_machine.Id);
await Service.DeleteAsync(_machine.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_machines = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/news"
@using Marechai.Database.Models
@inherits OwningComponentBase<NewsService>
@inject IStringLocalizer<NewsService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["News"]</h3>
@if (_news is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -55,11 +56,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_news = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_currentNews.Id);
await Service.DeleteAsync(_currentNews.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_news = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/people"
@using Marechai.Database.Models
@inherits OwningComponentBase<PeopleService>
@inject IStringLocalizer<PeopleService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["People"]</h3>
@if (_people is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_people = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_person.Id);
await Service.DeleteAsync(_person.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_people = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/processors"
@using Marechai.Database.Models
@inherits OwningComponentBase<ProcessorsService>
@inject IStringLocalizer<ProcessorsService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Processors"]</h3>
@if (_processors is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_processors = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_processor.Id);
await Service.DeleteAsync(_processor.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_processors = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/resolutions"
@using Marechai.Database.Models
@inherits OwningComponentBase<ResolutionsService>
@inject IStringLocalizer<ResolutionsService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Resolutions"]</h3>
@if (_resolutions is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_resolutions = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_resolution.Id);
await Service.DeleteAsync(_resolution.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_resolutions = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/screens"
@using Marechai.Database.Models
@inherits OwningComponentBase<ScreensService>
@inject IStringLocalizer<ScreensService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Screens"]</h3>
@if (_screens is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_screens = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_screen.Id);
await Service.DeleteAsync(_screen.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_screens = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -26,8 +26,11 @@
}
@page "/admin/sound_synths"
@using Marechai.Database.Models
@inherits OwningComponentBase<SoundSynthsService>
@inject IStringLocalizer<SoundSynthsService> L
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Sound synthesizers"]</h3>
@if (_soundSynths is null)

View File

@@ -28,6 +28,7 @@ using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components.Authorization;
namespace Marechai.Pages.Admin
{
@@ -53,11 +54,12 @@ namespace Marechai.Pages.Admin
_deleteInProgress = true;
_soundSynths = null;
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_soundSynth.Id);
await Service.DeleteAsync(_soundSynth.Id, (await UserManager.GetUserAsync(authState.User)).Id);
_soundSynths = await Service.GetAsync();
_deleteInProgress = false;

View File

@@ -86,7 +86,7 @@ namespace Marechai.Services
Country = c.Country.Name
}).FirstOrDefaultAsync();
public async Task UpdateAsync(CompanyViewModel viewModel)
public async Task UpdateAsync(CompanyViewModel viewModel, string userId)
{
Company model = await _context.Companies.FindAsync(viewModel.Id);
@@ -107,10 +107,10 @@ namespace Marechai.Services
model.Province = viewModel.Province;
model.PostalCode = viewModel.PostalCode;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(CompanyViewModel viewModel)
public async Task<int> CreateAsync(CompanyViewModel viewModel, string userId)
{
var model = new Company
{
@@ -122,7 +122,7 @@ namespace Marechai.Services
};
await _context.Companies.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
@@ -186,7 +186,7 @@ namespace Marechai.Services
Name = c.Name
}).ToListAsync();
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
Company item = await _context.Companies.FindAsync(id);
@@ -195,7 +195,7 @@ namespace Marechai.Services
_context.Companies.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<CompanyDescriptionViewModel> GetDescriptionAsync(int id) => await _context.
@@ -219,7 +219,8 @@ namespace Marechai.Services
}).
FirstOrDefaultAsync();
public async Task<int> CreateOrUpdateDescriptionAsync(int id, CompanyDescriptionViewModel description)
public async Task<int> CreateOrUpdateDescriptionAsync(int id, CompanyDescriptionViewModel description,
string userId)
{
CompanyDescription current = await _context.CompanyDescriptions.FirstOrDefaultAsync(d => d.CompanyId == id);
@@ -238,7 +239,7 @@ namespace Marechai.Services
current.Text = description.Markdown;
}
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return current.Id;
}

View File

@@ -50,7 +50,7 @@ namespace Marechai.Services
public async Task<List<CompanyLogo>> GetByCompany(int companyId) =>
await _context.CompanyLogos.Where(l => l.CompanyId == companyId).OrderBy(l => l.Year).ToListAsync();
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
CompanyLogo logo = await _context.CompanyLogos.Where(l => l.Id == id).FirstOrDefaultAsync();
@@ -58,7 +58,7 @@ namespace Marechai.Services
return;
_context.CompanyLogos.Remove(logo);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
if(File.Exists(Path.Combine(_webRootPath, "assets/logos", logo.Guid + ".svg")))
File.Delete(Path.Combine(_webRootPath, "assets/logos", logo.Guid + ".svg"));
@@ -100,7 +100,7 @@ namespace Marechai.Services
File.Delete(Path.Combine(_webRootPath, "assets/logos/thumbs/png/3x", logo.Guid + ".png"));
}
public async Task ChangeYearAsync(int id, int? year)
public async Task ChangeYearAsync(int id, int? year, string userId)
{
CompanyLogo logo = await _context.CompanyLogos.Where(l => l.Id == id).FirstOrDefaultAsync();
@@ -108,10 +108,10 @@ namespace Marechai.Services
return;
logo.Year = year;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(int companyId, Guid guid, int? year)
public async Task<int> CreateAsync(int companyId, Guid guid, int? year, string userId)
{
var logo = new CompanyLogo
{
@@ -119,7 +119,7 @@ namespace Marechai.Services
};
await _context.CompanyLogos.AddAsync(logo);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return logo.Id;
}

View File

@@ -53,7 +53,7 @@ namespace Marechai.Services
Id = d.Id, Name = d.Name, CompanyId = d.CompanyId
}).FirstOrDefaultAsync();
public async Task UpdateAsync(DocumentCompanyViewModel viewModel)
public async Task UpdateAsync(DocumentCompanyViewModel viewModel, string userId)
{
DocumentCompany model = await _context.DocumentCompanies.FindAsync(viewModel.Id);
@@ -63,10 +63,10 @@ namespace Marechai.Services
model.CompanyId = viewModel.CompanyId;
model.Name = viewModel.Name;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(DocumentCompanyViewModel viewModel)
public async Task<int> CreateAsync(DocumentCompanyViewModel viewModel, string userId)
{
var model = new DocumentCompany
{
@@ -74,12 +74,12 @@ namespace Marechai.Services
};
await _context.DocumentCompanies.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
DocumentCompany item = await _context.DocumentCompanies.FindAsync(id);
@@ -88,7 +88,7 @@ namespace Marechai.Services
_context.DocumentCompanies.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -56,7 +56,7 @@ namespace Marechai.Services
DisplayName = d.DisplayName, PersonId = d.PersonId
}).FirstOrDefaultAsync();
public async Task UpdateAsync(DocumentPersonViewModel viewModel)
public async Task UpdateAsync(DocumentPersonViewModel viewModel, string userId)
{
DocumentPerson model = await _context.DocumentPeople.FindAsync(viewModel.Id);
@@ -69,10 +69,10 @@ namespace Marechai.Services
model.DisplayName = viewModel.DisplayName;
model.PersonId = viewModel.PersonId;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(DocumentPersonViewModel viewModel)
public async Task<int> CreateAsync(DocumentPersonViewModel viewModel, string userId)
{
var model = new DocumentPerson
{
@@ -81,12 +81,12 @@ namespace Marechai.Services
};
await _context.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
DocumentPerson item = await _context.DocumentPeople.FindAsync(id);
@@ -95,7 +95,7 @@ namespace Marechai.Services
_context.DocumentPeople.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -45,7 +45,7 @@ namespace Marechai.Services
MachineId = g.MachineId
}).OrderBy(g => g.CompanyName).ThenBy(g => g.Name).ToListAsync();
public async Task DeleteAsync(long id)
public async Task DeleteAsync(long id, string userId)
{
GpusByMachine item = await _context.GpusByMachine.FindAsync(id);
@@ -54,10 +54,10 @@ namespace Marechai.Services
_context.GpusByMachine.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<long> CreateAsync(int gpuId, int machineId)
public async Task<long> CreateAsync(int gpuId, int machineId, string userId)
{
var item = new GpusByMachine
{
@@ -65,7 +65,7 @@ namespace Marechai.Services
};
await _context.GpusByMachine.AddAsync(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return item.Id;
}

View File

@@ -64,7 +64,7 @@ namespace Marechai.Services
DieSize = g.DieSize, Transistors = g.Transistors
}).FirstOrDefaultAsync();
public async Task UpdateAsync(GpuViewModel viewModel)
public async Task UpdateAsync(GpuViewModel viewModel, string userId)
{
Gpu model = await _context.Gpus.FindAsync(viewModel.Id);
@@ -81,10 +81,10 @@ namespace Marechai.Services
model.DieSize = viewModel.DieSize;
model.Transistors = viewModel.Transistors;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(GpuViewModel viewModel)
public async Task<int> CreateAsync(GpuViewModel viewModel, string userId)
{
var model = new Gpu
{
@@ -94,12 +94,12 @@ namespace Marechai.Services
};
await _context.Gpus.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
Gpu item = await _context.Gpus.FindAsync(id);
@@ -108,7 +108,7 @@ namespace Marechai.Services
_context.Gpus.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -46,7 +46,7 @@ namespace Marechai.Services
ProcessorId = e.ProcessorId, ExtensionId = e.ExtensionId
}).OrderBy(e => e.Extension).ToListAsync();
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
InstructionSetExtensionsByProcessor item = await _context.InstructionSetExtensionsByProcessor.FindAsync(id);
@@ -55,10 +55,10 @@ namespace Marechai.Services
_context.InstructionSetExtensionsByProcessor.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(int processorId, int extensionId)
public async Task<int> CreateAsync(int processorId, int extensionId, string userId)
{
var item = new InstructionSetExtensionsByProcessor
{
@@ -66,7 +66,7 @@ namespace Marechai.Services
};
await _context.InstructionSetExtensionsByProcessor.AddAsync(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return item.Id;
}

View File

@@ -50,7 +50,7 @@ namespace Marechai.Services
Extension = e.Extension, Id = e.Id
}).FirstOrDefaultAsync();
public async Task UpdateAsync(InstructionSetExtension viewModel)
public async Task UpdateAsync(InstructionSetExtension viewModel, string userId)
{
InstructionSetExtension model = await _context.InstructionSetExtensions.FindAsync(viewModel.Id);
@@ -59,10 +59,10 @@ namespace Marechai.Services
model.Extension = viewModel.Extension;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(InstructionSetExtension viewModel)
public async Task<int> CreateAsync(InstructionSetExtension viewModel, string userId)
{
var model = new InstructionSetExtension
{
@@ -70,12 +70,12 @@ namespace Marechai.Services
};
await _context.InstructionSetExtensions.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
InstructionSetExtension item = await _context.InstructionSetExtensions.FindAsync(id);
@@ -84,7 +84,7 @@ namespace Marechai.Services
_context.InstructionSetExtensions.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public bool VerifyUnique(string extension) =>

View File

@@ -50,7 +50,7 @@ namespace Marechai.Services
Name = e.Name, Id = e.Id
}).FirstOrDefaultAsync();
public async Task UpdateAsync(InstructionSet viewModel)
public async Task UpdateAsync(InstructionSet viewModel, string userId)
{
InstructionSet model = await _context.InstructionSets.FindAsync(viewModel.Id);
@@ -59,10 +59,10 @@ namespace Marechai.Services
model.Name = viewModel.Name;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(InstructionSet viewModel)
public async Task<int> CreateAsync(InstructionSet viewModel, string userId)
{
var model = new InstructionSet
{
@@ -70,12 +70,12 @@ namespace Marechai.Services
};
await _context.InstructionSets.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
InstructionSet item = await _context.InstructionSets.FindAsync(id);
@@ -84,7 +84,7 @@ namespace Marechai.Services
_context.InstructionSets.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public bool VerifyUnique(string name) =>

View File

@@ -51,7 +51,7 @@ namespace Marechai.Services
OsiApproved = l.OsiApproved, SPDX = l.SPDX, Text = l.Text
}).FirstOrDefaultAsync();
public async Task UpdateAsync(License viewModel)
public async Task UpdateAsync(License viewModel, string userId)
{
License model = await _context.Licenses.FindAsync(viewModel.Id);
@@ -65,10 +65,10 @@ namespace Marechai.Services
model.SPDX = viewModel.SPDX;
model.Text = viewModel.Text;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(License viewModel)
public async Task<int> CreateAsync(License viewModel, string userId)
{
var model = new License
{
@@ -77,12 +77,12 @@ namespace Marechai.Services
};
await _context.Licenses.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
License item = await _context.Licenses.FindAsync(id);
@@ -91,7 +91,7 @@ namespace Marechai.Services
_context.Licenses.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -51,7 +51,7 @@ namespace Marechai.Services
Id = m.Id, CompanyId = m.CompanyId, Name = m.Name
}).FirstOrDefaultAsync();
public async Task UpdateAsync(MachineFamilyViewModel viewModel)
public async Task UpdateAsync(MachineFamilyViewModel viewModel, string userId)
{
MachineFamily model = await _context.MachineFamilies.FindAsync(viewModel.Id);
@@ -61,10 +61,10 @@ namespace Marechai.Services
model.Name = viewModel.Name;
model.CompanyId = viewModel.CompanyId;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(MachineFamilyViewModel viewModel)
public async Task<int> CreateAsync(MachineFamilyViewModel viewModel, string userId)
{
var model = new MachineFamily
{
@@ -72,12 +72,12 @@ namespace Marechai.Services
};
await _context.MachineFamilies.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
MachineFamily item = await _context.MachineFamilies.FindAsync(id);
@@ -86,7 +86,7 @@ namespace Marechai.Services
_context.MachineFamilies.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -62,7 +62,7 @@ namespace Marechai.Services
WhiteBalance = p.WhiteBalance, OriginalExtension = p.OriginalExtension
}).FirstOrDefaultAsync();
public async Task UpdateAsync(MachinePhotoViewModel viewModel)
public async Task UpdateAsync(MachinePhotoViewModel viewModel, string userId)
{
MachinePhoto model = await _context.MachinePhotos.FindAsync(viewModel.Id);
@@ -104,10 +104,10 @@ namespace Marechai.Services
model.VerticalResolution = viewModel.VerticalResolution;
model.WhiteBalance = viewModel.WhiteBalance;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<Guid> CreateAsync(MachinePhotoViewModel viewModel)
public async Task<Guid> CreateAsync(MachinePhotoViewModel viewModel, string userId)
{
var model = new MachinePhoto
{
@@ -132,7 +132,7 @@ namespace Marechai.Services
};
await _context.MachinePhotos.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}

View File

@@ -72,7 +72,7 @@ namespace Marechai.Services
Type = m.Type, FamilyId = m.FamilyId
}).FirstOrDefaultAsync();
public async Task UpdateAsync(MachineViewModel viewModel)
public async Task UpdateAsync(MachineViewModel viewModel, string userId)
{
Machine model = await _context.Machines.FindAsync(viewModel.Id);
@@ -110,10 +110,10 @@ namespace Marechai.Services
if(news != null)
await _context.News.AddAsync(news);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(MachineViewModel viewModel)
public async Task<int> CreateAsync(MachineViewModel viewModel, string userId)
{
var model = new Machine
{
@@ -122,7 +122,7 @@ namespace Marechai.Services
};
await _context.Machines.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
var news = new News
{
@@ -148,7 +148,7 @@ namespace Marechai.Services
if(news != null)
{
await _context.News.AddAsync(news);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
return model.Id;
@@ -213,7 +213,7 @@ namespace Marechai.Services
return model;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
Machine item = await _context.Machines.FindAsync(id);
@@ -222,7 +222,7 @@ namespace Marechai.Services
_context.Machines.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -46,7 +46,7 @@ namespace Marechai.Services
Speed = m.Speed, MachineId = m.MachineId
}).OrderBy(m => m.Type).ThenBy(m => m.Usage).ThenBy(m => m.Size).ThenBy(m => m.Speed).ToListAsync();
public async Task DeleteAsync(long id)
public async Task DeleteAsync(long id, string userId)
{
MemoryByMachine item = await _context.MemoryByMachine.FindAsync(id);
@@ -55,11 +55,11 @@ namespace Marechai.Services
_context.MemoryByMachine.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<long> CreateAsync(int machineId, MemoryType type, MemoryUsage usage, long? size,
double? speed)
double? speed, string userId)
{
var item = new MemoryByMachine
{
@@ -68,7 +68,7 @@ namespace Marechai.Services
};
await _context.MemoryByMachine.AddAsync(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return item.Id;
}

View File

@@ -23,10 +23,8 @@
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Marechai.Database;
using Marechai.Database.Models;
@@ -50,7 +48,8 @@ namespace Marechai.Services
public async Task<List<NewsViewModel>> GetAsync() => await _context.News.OrderByDescending(n => n.Date).
Select(n => new NewsViewModel
{
Id = n.Id, Timestamp = n.Date, Type = n.Type, AffectedId = n.AddedId
Id = n.Id, Timestamp = n.Date,
Type = n.Type, AffectedId = n.AddedId
}).ToListAsync();
public List<NewsViewModel> GetNews()
@@ -124,7 +123,7 @@ namespace Marechai.Services
return news;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
News item = await _context.News.FindAsync(id);
@@ -133,7 +132,7 @@ namespace Marechai.Services
_context.News.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -56,7 +56,7 @@ namespace Marechai.Services
Facebook = p.Facebook, Photo = p.Photo, Alias = p.Alias, DisplayName = p.DisplayName
}).FirstOrDefaultAsync();
public async Task UpdateAsync(PersonViewModel viewModel)
public async Task UpdateAsync(PersonViewModel viewModel, string userId)
{
Person model = await _context.People.FindAsync(viewModel.Id);
@@ -75,10 +75,10 @@ namespace Marechai.Services
model.Alias = viewModel.Alias;
model.DisplayName = viewModel.DisplayName;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(PersonViewModel viewModel)
public async Task<int> CreateAsync(PersonViewModel viewModel, string userId)
{
var model = new Person
{
@@ -89,12 +89,12 @@ namespace Marechai.Services
};
await _context.People.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
Person item = await _context.People.FindAsync(id);
@@ -103,7 +103,7 @@ namespace Marechai.Services
_context.People.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -46,7 +46,7 @@ namespace Marechai.Services
ProcessorId = p.ProcessorId, MachineId = p.MachineId, Speed = p.Speed
}).OrderBy(p => p.CompanyName).ThenBy(p => p.Name).ToListAsync();
public async Task DeleteAsync(long id)
public async Task DeleteAsync(long id, string userId)
{
ProcessorsByMachine item = await _context.ProcessorsByMachine.FindAsync(id);
@@ -55,10 +55,10 @@ namespace Marechai.Services
_context.ProcessorsByMachine.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<long> CreateAsync(int processorId, int machineId, float? speed)
public async Task<long> CreateAsync(int processorId, int machineId, float? speed, string userId)
{
var item = new ProcessorsByMachine
{
@@ -66,7 +66,7 @@ namespace Marechai.Services
};
await _context.ProcessorsByMachine.AddAsync(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return item.Id;
}

View File

@@ -80,7 +80,7 @@ namespace Marechai.Services
L3 = p.L3, InstructionSet = p.InstructionSet.Name, InstructionSetId = p.InstructionSetId
}).FirstOrDefaultAsync();
public async Task UpdateAsync(ProcessorViewModel viewModel)
public async Task UpdateAsync(ProcessorViewModel viewModel, string userId)
{
Processor model = await _context.Processors.FindAsync(viewModel.Id);
@@ -113,10 +113,10 @@ namespace Marechai.Services
model.ThreadsPerCore = viewModel.ThreadsPerCore;
model.Transistors = viewModel.Transistors;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(ProcessorViewModel viewModel)
public async Task<int> CreateAsync(ProcessorViewModel viewModel, string userId)
{
var model = new Processor
{
@@ -132,12 +132,12 @@ namespace Marechai.Services
};
await _context.Processors.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
Processor item = await _context.Processors.FindAsync(id);
@@ -146,7 +146,7 @@ namespace Marechai.Services
_context.Processors.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -54,7 +54,7 @@ namespace Marechai.Services
ThenBy(r => r.Resolution.Colors).ThenBy(r => r.Resolution.Palette).
ToList();
public async Task DeleteAsync(long id)
public async Task DeleteAsync(long id, string userId)
{
ResolutionsByGpu item = await _context.ResolutionsByGpu.FindAsync(id);
@@ -63,10 +63,10 @@ namespace Marechai.Services
_context.ResolutionsByGpu.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<long> CreateAsync(int resolutionId, int gpuId)
public async Task<long> CreateAsync(int resolutionId, int gpuId, string userId)
{
var item = new ResolutionsByGpu
{
@@ -74,7 +74,7 @@ namespace Marechai.Services
};
await _context.ResolutionsByGpu.AddAsync(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return item.Id;
}

View File

@@ -54,7 +54,7 @@ namespace Marechai.Services
ThenBy(r => r.Resolution.Colors).ThenBy(r => r.Resolution.Palette).
ToList();
public async Task DeleteAsync(long id)
public async Task DeleteAsync(long id, string userId)
{
ResolutionsByScreen item = await _context.ResolutionsByScreen.FindAsync(id);
@@ -63,10 +63,10 @@ namespace Marechai.Services
_context.ResolutionsByScreen.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<long> CreateAsync(int resolutionId, int screenId)
public async Task<long> CreateAsync(int resolutionId, int screenId, string userId)
{
var item = new ResolutionsByScreen
{
@@ -74,7 +74,7 @@ namespace Marechai.Services
};
await _context.ResolutionsByScreen.AddAsync(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return item.Id;
}

View File

@@ -53,7 +53,7 @@ namespace Marechai.Services
Palette = r.Palette, Chars = r.Chars, Grayscale = r.Grayscale
}).FirstOrDefaultAsync();
public async Task UpdateAsync(ResolutionViewModel viewModel)
public async Task UpdateAsync(ResolutionViewModel viewModel, string userId)
{
Resolution model = await _context.Resolutions.FindAsync(viewModel.Id);
@@ -67,10 +67,10 @@ namespace Marechai.Services
model.Palette = viewModel.Palette;
model.Width = viewModel.Width;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(ResolutionViewModel viewModel)
public async Task<int> CreateAsync(ResolutionViewModel viewModel, string userId)
{
var model = new Resolution
{
@@ -79,12 +79,12 @@ namespace Marechai.Services
};
await _context.Resolutions.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
Resolution item = await _context.Resolutions.FindAsync(id);
@@ -93,7 +93,7 @@ namespace Marechai.Services
_context.Resolutions.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -60,7 +60,7 @@ namespace Marechai.Services
}
}).ToListAsync();
public async Task DeleteAsync(long id)
public async Task DeleteAsync(long id, string userId)
{
ScreensByMachine item = await _context.ScreensByMachine.FindAsync(id);
@@ -69,10 +69,10 @@ namespace Marechai.Services
_context.ScreensByMachine.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<long> CreateAsync(int machineId, int screenId)
public async Task<long> CreateAsync(int machineId, int screenId, string userId)
{
if(_context.ScreensByMachine.Any(s => s.MachineId == machineId && s.ScreenId == screenId))
return 0;
@@ -83,7 +83,7 @@ namespace Marechai.Services
};
await _context.ScreensByMachine.AddAsync(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return item.Id;
}

View File

@@ -75,7 +75,7 @@ namespace Marechai.Services
NativeResolutionId = s.NativeResolutionId, Type = s.Type, Width = s.Width
}).FirstOrDefaultAsync();
public async Task UpdateAsync(ScreenViewModel viewModel)
public async Task UpdateAsync(ScreenViewModel viewModel, string userId)
{
Screen model = await _context.Screens.FindAsync(viewModel.Id);
@@ -94,10 +94,10 @@ namespace Marechai.Services
model.Type = viewModel.Type;
model.Width = viewModel.Width;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(ScreenViewModel viewModel)
public async Task<int> CreateAsync(ScreenViewModel viewModel, string userId)
{
var model = new Screen
{
@@ -106,12 +106,12 @@ namespace Marechai.Services
};
await _context.Screens.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
Screen item = await _context.Screens.FindAsync(id);
@@ -120,7 +120,7 @@ namespace Marechai.Services
_context.Screens.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -46,7 +46,7 @@ namespace Marechai.Services
SoundSynthId = g.SoundSynthId, MachineId = g.MachineId
}).OrderBy(g => g.CompanyName).ThenBy(g => g.Name).ToListAsync();
public async Task DeleteAsync(long id)
public async Task DeleteAsync(long id, string userId)
{
SoundByMachine item = await _context.SoundByMachine.FindAsync(id);
@@ -55,10 +55,10 @@ namespace Marechai.Services
_context.SoundByMachine.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<long> CreateAsync(int soundSynthId, int machineId)
public async Task<long> CreateAsync(int soundSynthId, int machineId, string userId)
{
var item = new SoundByMachine
{
@@ -66,7 +66,7 @@ namespace Marechai.Services
};
await _context.SoundByMachine.AddAsync(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return item.Id;
}

View File

@@ -75,7 +75,7 @@ namespace Marechai.Services
Type = s.Type
}).FirstOrDefaultAsync();
public async Task UpdateAsync(SoundSynthViewModel viewModel)
public async Task UpdateAsync(SoundSynthViewModel viewModel, string userId)
{
SoundSynth model = await _context.SoundSynths.FindAsync(viewModel.Id);
@@ -93,10 +93,10 @@ namespace Marechai.Services
model.SquareWave = viewModel.SquareWave;
model.WhiteNoise = viewModel.WhiteNoise;
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<int> CreateAsync(SoundSynthViewModel viewModel)
public async Task<int> CreateAsync(SoundSynthViewModel viewModel, string userId)
{
var model = new SoundSynth
{
@@ -107,12 +107,12 @@ namespace Marechai.Services
};
await _context.SoundSynths.AddAsync(model);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return model.Id;
}
public async Task DeleteAsync(int id)
public async Task DeleteAsync(int id, string userId)
{
SoundSynth item = await _context.SoundSynths.FindAsync(id);
@@ -121,7 +121,7 @@ namespace Marechai.Services
_context.SoundSynths.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
}
}

View File

@@ -47,7 +47,7 @@ namespace Marechai.Services
MachineId = s.MachineId
}).OrderBy(s => s.Type).ThenBy(s => s.Interface).ThenBy(s => s.Capacity).ToListAsync();
public async Task DeleteAsync(long id)
public async Task DeleteAsync(long id, string userId)
{
StorageByMachine item = await _context.StorageByMachine.FindAsync(id);
@@ -56,11 +56,11 @@ namespace Marechai.Services
_context.StorageByMachine.Remove(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
}
public async Task<long> CreateAsync(int machineId, StorageType type, StorageInterface @interface,
long? capacity)
long? capacity, string userId)
{
var item = new StorageByMachine
{
@@ -68,7 +68,7 @@ namespace Marechai.Services
};
await _context.StorageByMachine.AddAsync(item);
await _context.SaveChangesAsync();
await _context.SaveChangesWithUserAsync(userId);
return item.Id;
}