Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Lapeev authored and Konstantin Lapeev committed Aug 24, 2023
2 parents 560a9ca + 85a11df commit f8c8d9c
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CrmNx.Libs.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup Label="Auto Versioning">
<VersionNumber>1.0.27</VersionNumber>
<VersionNumber>1.0.28</VersionNumber>
<BuildDate>$([System.DateTime]::UtcNow.AddHours(3).ToString(`yyyyMMdd-HHmm`))</BuildDate>
<Version>$(VersionNumber)-$(BuildDate)</Version>
<VersionSuffix>rc</VersionSuffix>
Expand Down
5 changes: 1 addition & 4 deletions CrmNx.Xrm.Identity/Dto/CrmSystemUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ public CrmSystemUser() : base(EntityLogicalName)
public sealed override Guid Id
{
get => GetAttributeValue<Guid>(PrimaryIdAttribute);
set
{
SetAttributeValue(PrimaryIdAttribute, value);
}
set => SetAttributeValue(PrimaryIdAttribute, value);
}

public string DomainName
Expand Down
2 changes: 0 additions & 2 deletions CrmNx.Xrm.Identity/Dto/EntityIdComparer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using CrmNx.Xrm.Toolkit;
using System;
using System.Collections.Generic;
using System.Text;

namespace CrmNx.Xrm.Identity.Dto
{
Expand Down
2 changes: 1 addition & 1 deletion CrmNx.Xrm.Toolkit/Extensions/EntityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static TEntity ToEntity<TEntity>(this Entity otherEntity)

foreach (var (keyName, value) in otherEntity.Attributes)
{
entity.Attributes.Add(keyName, value);
entity.Attributes[keyName] = value;
}

foreach (var (keyName, value) in otherEntity.FormattedValues)
Expand Down
20 changes: 0 additions & 20 deletions CrmNx.Xrm.Toolkit/Infrastructure/WebApiMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,7 @@ protected virtual async Task<DateTimeBehavior> GetDateTimeBehaviorAttributeAsync

Parameters =
{
// {"$select", "LogicalName,Format,DateTimeBehavior"},
{ "$select", "LogicalName,Format,DateTimeBehavior" },
// {
// "$filter",
// "DateTimeBehavior ne null and Format eq Microsoft.Dynamics.CRM.DateTimeFormat'DateOnly'"
// }
}
};

Expand All @@ -194,21 +189,6 @@ protected virtual async Task<DateTimeBehavior> GetDateTimeBehaviorAttributeAsync
behavior = (DateTimeBehavior)parsedValue;
}
}
catch (Exception)
{
throw;
}
// catch (WebApiException ex)
// {
// // if (Equals(ex.StatusCode, HttpStatusCode.NotFound))
// // {
// // isDateOnly = false;
// // }
// // else
// // {
// // throw;
// // }
// }
finally
{
watch.Stop();
Expand Down
38 changes: 38 additions & 0 deletions Tests/UnitTests/EntityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,43 @@ public async Task Retrieve_Request_Have_HttpHeader_Prefer_Included_ODataAnnotati

requestHeaders.GetValues("Prefer").Contains("odata.include-annotations=\"*\"").Should().BeTrue();
}

[Fact]
public void Convert_Entity_To_ProxyEntity_By_Attr_When_ID_IS_Overriden_Then_ID_Correct()
{
Entity entity = new Entity("account")
{
["accountid"] = new Guid("00000000-0000-0000-0000-000000000001"),
["statecode"] = 1
};

Account account = entity.ToEntity<Account>();
account.Id.Should().Be(new Guid("00000000-0000-0000-0000-000000000001"));
}

[Fact]
public void Convert_Entity_To_ProxyEntity_When_ID_IS_Overriden_Then_ID_Correct()
{
Entity entity = new Entity("account")
{
Id = new Guid("00000000-0000-0000-0000-000000000001")
};

Account account = entity.ToEntity<Account>();
account.Id.Should().Be(new Guid("00000000-0000-0000-0000-000000000001"));
}

[Fact]
public void Convert_Entity_To_ProxyEntity_When_ID_IS_Overriden_AND_HAVE_ATTR_Then_ID_Correct()
{
Entity entity = new Entity("account")
{
Id = new Guid("00000000-0000-0000-0000-000000000001"),
["accountid"] = new Guid("00000000-0000-0000-0000-000000000002")
};

Account account = entity.ToEntity<Account>();
account.Id.Should().Be(new Guid("00000000-0000-0000-0000-000000000002"));
}
}
}

0 comments on commit f8c8d9c

Please sign in to comment.