Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Last active June 19, 2024 20:55
Show Gist options
  • Save dcomartin/d4b455674bce7d6d7ad9e16f007b31b1 to your computer and use it in GitHub Desktop.
Save dcomartin/d4b455674bce7d6d7ad9e16f007b31b1 to your computer and use it in GitHub Desktop.
public enum OfferingType
{
Course,
Ebook,
Book,
Template,
OfflineCourse,
}
public sealed record Product(int Id, OfferingType Type);
public sealed class ProductHandler(ResourcesHelper _resourcesHelper)
{
public void DoStuff(Product product)
{
if (product.Type == OfferingType.Template ||
product.Type == OfferingType.Ebook ||
product.Type == OfferingType.OfflineCourse)
{
var fileName = _resourcesHelper.GetDefaultDownloadFileName(product.Type);
var downloadUrl = _resourcesHelper.GetDownloadUrl(product.Type);
}
}
}
public sealed class ResourcesHelper
{
public string? GetDownloadUrl(OfferingType offeringType)
{
if (offeringType == OfferingType.Template ||
offeringType == OfferingType.Ebook ||
offeringType == OfferingType.OfflineCourse)
{
// some code to do this...
return "TODO: get the download URL";
}
return null;
}
public string? GetDefaultDownloadFileName(OfferingType offeringType)
{
if (offeringType == OfferingType.Template ||
offeringType == OfferingType.Ebook ||
offeringType == OfferingType.OfflineCourse)
{
// some code to do this...
return "TODO: get the file name";
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment