* Persist and expose Umbraco system dates as UTC (#19705) * Updated persistence DTOs defining default dates to use UTC. * Remove ForceToUtc = false from all persistence DTO attributes (default when not specified is true). * Removed use of SpecifyKind setting dates to local. * Removed unnecessary Utc suffixes on properties. * Persist current date time with UtcNow. * Removed further necessary Utc suffixes and fixed failing unit tests. * Added migration for SQL server to update database date default constraints. * Added comment justifying not providing a migration for SQLite default date constraints. * Ensure UTC for datetimes created from persistence DTOs. * Ensure UTC when creating dates for published content rendering in Razor and outputting in delivery API. * Fixed migration SQL syntax. * Introduced AuditItemFactory for creating entries for the backoffice document history, so we can control the UTC setting on the retrieved persisted dates. * Ensured UTC dates are retrieved for document versions. * Ensured UTC is returned for backoffice display of last edited and published for variant content. * Fixed SQLite syntax for default current datetime. * Apply suggestions from code review Co-authored-by: Laura Neto <12862535+lauraneto@users.noreply.github.com> * Further updates from code review. --------- Co-authored-by: Laura Neto <12862535+lauraneto@users.noreply.github.com> * Migrate system dates from local server time to UTC (#19798) * Add settings for the migration. * Add migration and implement for SQL server. * Implement for SQLite. * Fixes from testing with SQL Server. * Fixes from testing with SQLite. * Code tidy. * Cleaned up usings. * Removed audit log date from conversion. * Removed webhook log date from conversion. * Updated update date initialization on saving dictionary items. * Updated filter on log queries. * Use timezone ID instead of system name to work cross-culture. --------- Co-authored-by: Laura Neto <12862535+lauraneto@users.noreply.github.com>
169 lines
4.2 KiB
C#
169 lines
4.2 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
using Umbraco.Cms.Core.Models.Entities;
|
|
using Umbraco.Cms.Tests.Common.Builders.Interfaces;
|
|
|
|
namespace Umbraco.Cms.Tests.Common.Builders;
|
|
|
|
public class DocumentEntitySlimBuilder
|
|
: BuilderBase<DocumentEntitySlim>,
|
|
IWithIdBuilder,
|
|
IWithKeyBuilder,
|
|
IWithCreatorIdBuilder,
|
|
IWithCreateDateBuilder,
|
|
IWithUpdateDateBuilder,
|
|
IWithNameBuilder,
|
|
IWithLevelBuilder,
|
|
IWithPathBuilder,
|
|
IWithSortOrderBuilder,
|
|
IWithParentIdBuilder
|
|
{
|
|
private string _contentTypeAlias;
|
|
private string _contentTypeIcon;
|
|
private string _contentTypeThumbnail;
|
|
private DateTime? _createDate;
|
|
private int? _creatorId;
|
|
private bool? _hasChildren;
|
|
|
|
private int? _id;
|
|
private Guid? _key;
|
|
private int? _level;
|
|
private string _name;
|
|
private int? _parentId;
|
|
private string _path;
|
|
private bool? _published;
|
|
private int? _sortOrder;
|
|
private DateTime? _updateDate;
|
|
|
|
DateTime? IWithCreateDateBuilder.CreateDate
|
|
{
|
|
get => _createDate;
|
|
set => _createDate = value;
|
|
}
|
|
|
|
int? IWithCreatorIdBuilder.CreatorId
|
|
{
|
|
get => _creatorId;
|
|
set => _creatorId = value;
|
|
}
|
|
|
|
int? IWithIdBuilder.Id
|
|
{
|
|
get => _id;
|
|
set => _id = value;
|
|
}
|
|
|
|
Guid? IWithKeyBuilder.Key
|
|
{
|
|
get => _key;
|
|
set => _key = value;
|
|
}
|
|
|
|
int? IWithLevelBuilder.Level
|
|
{
|
|
get => _level;
|
|
set => _level = value;
|
|
}
|
|
|
|
string IWithNameBuilder.Name
|
|
{
|
|
get => _name;
|
|
set => _name = value;
|
|
}
|
|
|
|
int? IWithParentIdBuilder.ParentId
|
|
{
|
|
get => _parentId;
|
|
set => _parentId = value;
|
|
}
|
|
|
|
string IWithPathBuilder.Path
|
|
{
|
|
get => _path;
|
|
set => _path = value;
|
|
}
|
|
|
|
int? IWithSortOrderBuilder.SortOrder
|
|
{
|
|
get => _sortOrder;
|
|
set => _sortOrder = value;
|
|
}
|
|
|
|
DateTime? IWithUpdateDateBuilder.UpdateDate
|
|
{
|
|
get => _updateDate;
|
|
set => _updateDate = value;
|
|
}
|
|
|
|
public DocumentEntitySlimBuilder WithHasChildren(bool hasChildren)
|
|
{
|
|
_hasChildren = hasChildren;
|
|
return this;
|
|
}
|
|
|
|
public DocumentEntitySlimBuilder WithPublished(bool published)
|
|
{
|
|
_published = published;
|
|
return this;
|
|
}
|
|
|
|
public DocumentEntitySlimBuilder WithContentTypeAlias(string contentTypeAlias)
|
|
{
|
|
_contentTypeAlias = contentTypeAlias;
|
|
return this;
|
|
}
|
|
|
|
public DocumentEntitySlimBuilder WithContentTypeIcon(string contentTypeIcon)
|
|
{
|
|
_contentTypeIcon = contentTypeIcon;
|
|
return this;
|
|
}
|
|
|
|
public DocumentEntitySlimBuilder WithContentTypeThumbnail(string contentTypeThumbnail)
|
|
{
|
|
_contentTypeThumbnail = contentTypeThumbnail;
|
|
return this;
|
|
}
|
|
|
|
public override DocumentEntitySlim Build()
|
|
{
|
|
var id = _id ?? 1;
|
|
var key = _key ?? Guid.NewGuid();
|
|
var createDate = _createDate ?? DateTime.UtcNow;
|
|
var updateDate = _updateDate ?? DateTime.UtcNow;
|
|
var name = _name ?? Guid.NewGuid().ToString();
|
|
var creatorId = _creatorId ?? 1;
|
|
var level = _level ?? 1;
|
|
var path = _path ?? $"-1,{id}";
|
|
var sortOrder = _sortOrder ?? 0;
|
|
var parentId = _parentId ?? -1;
|
|
var icon = _contentTypeIcon ?? string.Empty;
|
|
var thumbnail = _contentTypeThumbnail ?? string.Empty;
|
|
var contentTypeAlias = _contentTypeAlias ?? string.Empty;
|
|
var hasChildren = _hasChildren ?? false;
|
|
var published = _published ?? false;
|
|
|
|
var documentEntitySlim = new DocumentEntitySlim
|
|
{
|
|
Id = id,
|
|
Key = key,
|
|
CreateDate = createDate,
|
|
UpdateDate = updateDate,
|
|
Name = name,
|
|
CreatorId = creatorId,
|
|
Level = level,
|
|
Path = path,
|
|
SortOrder = sortOrder,
|
|
ParentId = parentId,
|
|
ContentTypeIcon = icon,
|
|
ContentTypeThumbnail = thumbnail,
|
|
ContentTypeAlias = contentTypeAlias,
|
|
HasChildren = hasChildren,
|
|
Published = published
|
|
};
|
|
|
|
return documentEntitySlim;
|
|
}
|
|
}
|