Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Noor Drummond committed Oct 16, 2024
1 parent d21e5e6 commit 48c01ea
Showing 1 changed file with 1 addition and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using N3O.Umbraco.Content;
using N3O.Umbraco.Crm.Lookups;
using N3O.Umbraco.Crowdfunding.Content;
using N3O.Umbraco.Crowdfunding.Models;
using N3O.Umbraco.Exceptions;
using N3O.Umbraco.Crowdfunding.Models;
using N3O.Umbraco.Giving.Extensions;
using N3O.Umbraco.Giving.Models;
using N3O.Umbraco.Json;
Expand All @@ -18,26 +14,6 @@ public static CrowdfunderData GetCrowdfunderData(this IAllocation allocation, IJ

return allocation.Extensions.Get<CrowdfunderData>(jsonProvider, Allocations.Extensions.Key);
}

public static string GetCrowdfunderName(this IAllocation allocation, IJsonProvider jsonProvider, IContentLocator contentLocator) {
if (!HasCrowdfunderData(allocation)) {
return null;
}

var extensionData = allocation.Extensions.Get<CrowdfunderData>(jsonProvider, Allocations.Extensions.Key);

ICrowdfunderContent crowdfunderContent;

if (extensionData.Type == CrowdfunderTypes.Campaign) {
crowdfunderContent = contentLocator.ById<CampaignContent>(extensionData.Id);
} else if (extensionData.Type == CrowdfunderTypes.Fundraiser) {
crowdfunderContent = contentLocator.ById<FundraiserContent>(extensionData.Id);
} else {
throw UnrecognisedValueException.For(extensionData.Type);
}

return crowdfunderContent.Name;
}

public static bool HasCrowdfunderData(this IAllocation allocation) {
return allocation.Extensions?.ContainsKey(Allocations.Extensions.Key) == true;
Expand Down

0 comments on commit 48c01ea

Please sign in to comment.