diff --git a/Api/Functions/CreateLinkBundle.cs b/Api/Functions/CreateLinkBundle.cs
index 13f796f..2f183cf 100644
--- a/Api/Functions/CreateLinkBundle.cs
+++ b/Api/Functions/CreateLinkBundle.cs
@@ -48,6 +48,15 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymou
linkBundle.Provider = clientPrincipal.IdentityProvider;
}
+ // Set the DateTime property of the LinkBundle to the current date and time
+ linkBundle.CreatedDate = DateTime.UtcNow;
+
+ // Set the referrer data of the LinkBundle to the referrer data from the request headers
+ if (req.Headers.TryGetValues("Referer", out var referrerValues))
+ {
+ linkBundle.ReferrerData = referrerValues.FirstOrDefault();
+ }
+
try
{
var databaseName = configuration["COSMOSDB_DATABASE"];
diff --git a/Api/Functions/GetLinkBundle.cs b/Api/Functions/GetLinkBundle.cs
index 709f9b2..e16f9bf 100644
--- a/Api/Functions/GetLinkBundle.cs
+++ b/Api/Functions/GetLinkBundle.cs
@@ -40,9 +40,18 @@ public async Task Run(
return await req.CreateJsonResponse(HttpStatusCode.NotFound, "No LinkBundle found for this vanity url");
}
+ var linkBundle = result.First();
+
+ // Increment the Clicks property of each Link
+ foreach (var link in linkBundle.Links)
+ {
+ link.Clicks++;
+ // link.CreatedDate = DateTime.UtcNow;
+ }
+
var response = req.CreateResponse(HttpStatusCode.OK);
- await response.WriteAsJsonAsync(result.First());
+ await response.WriteAsJsonAsync(linkBundle);
return response;
}
}
-}
\ No newline at end of file
+}
diff --git a/Client/Shared/LinkBundleDetails.razor b/Client/Shared/LinkBundleDetails.razor
index 739d04e..541601a 100644
--- a/Client/Shared/LinkBundleDetails.razor
+++ b/Client/Shared/LinkBundleDetails.razor
@@ -40,6 +40,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -134,4 +144,4 @@
{
StateContainer.OnChange -= StateHasChanged;
}
-}
\ No newline at end of file
+}
diff --git a/Client/Shared/LinkBundleItem.razor b/Client/Shared/LinkBundleItem.razor
index 8f73783..a3d0784 100644
--- a/Client/Shared/LinkBundleItem.razor
+++ b/Client/Shared/LinkBundleItem.razor
@@ -32,6 +32,8 @@
@link.Description
@link.Url
+
Clicks: @link.Clicks
+
Created Date: @link.CreatedDate.ToString("g")
diff --git a/Shared/Link.cs b/Shared/Link.cs
index d9d6857..b7f4f3c 100644
--- a/Shared/Link.cs
+++ b/Shared/Link.cs
@@ -15,5 +15,9 @@ public class Link
public string Description { get; set; }
[JsonPropertyName("image")]
public string Image { get; set; }
+ [JsonPropertyName("clicks")]
+ public int Clicks { get; set; }
+ [JsonPropertyName("createdDate")]
+ public DateTime CreatedDate { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/Shared/LinkBundle.cs b/Shared/LinkBundle.cs
index 1433db0..fd67149 100644
--- a/Shared/LinkBundle.cs
+++ b/Shared/LinkBundle.cs
@@ -19,5 +19,9 @@ public class LinkBundle
public string Provider { get; set; }
[JsonPropertyName("links")]
public List Links { get; set; } = new List();
+ [JsonPropertyName("createdDate")]
+ public DateTime CreatedDate { get; set; }
+ [JsonPropertyName("referrerData")]
+ public string ReferrerData { get; set; }
}
-}
\ No newline at end of file
+}