Browse Source

Just a small style improvement.

pull/470/head
Sebastian 7 years ago
parent
commit
c727114337
  1. 5
      backend/src/Squidex.Domain.Apps.Entities/Apps/State/AppState.cs
  2. 5
      backend/src/Squidex.Domain.Apps.Entities/Assets/State/AssetFolderState.cs
  3. 4
      backend/src/Squidex.Domain.Apps.Entities/Assets/State/AssetState.cs
  4. 13
      backend/src/Squidex.Infrastructure/Commands/Is.cs

5
backend/src/Squidex.Domain.Apps.Entities/Apps/State/AppState.cs

@ -10,6 +10,7 @@ using System.Runtime.Serialization;
using Squidex.Domain.Apps.Core.Apps; using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Core.Contents; using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Events.Apps; using Squidex.Domain.Apps.Events.Apps;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
@ -68,7 +69,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.State
return true; return true;
} }
case AppUpdated e when !string.Equals(e.Label, Label) || !string.Equals(e.Description, Description): case AppUpdated e when Is.Change(Label, e.Label) || Is.Change(Description, e.Description):
{ {
SimpleMapper.Map(e, this); SimpleMapper.Map(e, this);
@ -81,7 +82,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.State
case AppImageRemoved e when Image != null: case AppImageRemoved e when Image != null:
return UpdateImage(e, ev => null); return UpdateImage(e, ev => null);
case AppPlanChanged e when !string.Equals(Plan?.PlanId, e.PlanId): case AppPlanChanged e when Is.Change(Plan?.PlanId, e.PlanId):
return UpdatePlan(e, ev => AppPlan.Build(ev.Actor, ev.PlanId)); return UpdatePlan(e, ev => AppPlan.Build(ev.Actor, ev.PlanId));
case AppPlanReset e when Plan != null: case AppPlanReset e when Plan != null:

5
backend/src/Squidex.Domain.Apps.Entities/Assets/State/AssetFolderState.cs

@ -9,6 +9,7 @@ using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Squidex.Domain.Apps.Events.Assets; using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
@ -41,14 +42,14 @@ namespace Squidex.Domain.Apps.Entities.Assets.State
return true; return true;
} }
case AssetFolderRenamed e when e.FolderName != FolderName: case AssetFolderRenamed e when Is.ChangeWhenDefined(FolderName, e.FolderName):
{ {
FolderName = e.FolderName; FolderName = e.FolderName;
return true; return true;
} }
case AssetFolderMoved e when e.ParentId != ParentId: case AssetFolderMoved e when Is.Change(ParentId, e.ParentId):
{ {
ParentId = e.ParentId; ParentId = e.ParentId;

4
backend/src/Squidex.Domain.Apps.Entities/Assets/State/AssetState.cs

@ -102,14 +102,14 @@ namespace Squidex.Domain.Apps.Entities.Assets.State
{ {
var hasChanged = false; var hasChanged = false;
if (Is.Change(FileName, e.FileName)) if (Is.ChangeWhenDefined(FileName, e.FileName))
{ {
FileName = e.FileName; FileName = e.FileName;
hasChanged = true; hasChanged = true;
} }
if (Is.Change(Slug, e.Slug)) if (Is.ChangeWhenDefined(Slug, e.Slug))
{ {
Slug = e.Slug; Slug = e.Slug;

13
backend/src/Squidex.Infrastructure/Commands/Is.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
@ -12,7 +13,17 @@ namespace Squidex.Infrastructure.Commands
{ {
public static class Is public static class Is
{ {
public static bool Change(string? oldValue, string? newValue) public static bool Change(Guid oldValue, Guid newValue)
{
return !Equals(oldValue, newValue);
}
public static bool Change(string? oldValue, string newValue)
{
return !Equals(oldValue, newValue);
}
public static bool ChangeWhenDefined(string? oldValue, string? newValue)
{ {
return !string.IsNullOrWhiteSpace(newValue) && !string.Equals(oldValue, newValue); return !string.IsNullOrWhiteSpace(newValue) && !string.Equals(oldValue, newValue);
} }

Loading…
Cancel
Save