Error executing template "/Designs/Hags2024/Paragraph/h24-hags-connect-collections-ui.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.RazorEngine_94935a6f264e4ba2a0e5cf85826c055c.Execute() in B:\Projects\Hags_Dw915\Files\Templates\Designs\Hags2024\Paragraph\h24-hags-connect-collections-ui.cshtml:line 29
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
2 @using System.Web.Optimization;
3 @using Dynamicweb.Frontend;
4 @using Dynamicweb.Configuration;
5 @using HagsWeb.Library.BusinessObjects.UsersLists;
6 @using HagsWeb.Library.State;
7 @using Microsoft.Web.Administration;
8 @using HagsWeb.Library.Ajax;
9 @using Dynamicweb.Ecommerce.Variants;
10 @using System.Collections.Generic;
11 @using HagsWeb.Library.Methods.ProductProperties;
12
13
14 @{
15 Dynamicweb.Frontend.PageView collectionPage = Dynamicweb.Frontend.PageView.Current() ?? Dynamicweb.Frontend.PageView.Current();
16 Dynamicweb.Content.Area collectionArea = new Dynamicweb.Content.AreaService().GetArea(collectionPage.AreaID);
17 int currentPage = collectionArea.ID;
18
19 string printShout = Translate("SaveOrPrint", "Save or Print your Product PDF ");
20 string altCopy = Translate("RemoveFromCollection", "Remove from my collection");
21 string removeCopy = Translate("RemoveFromCollection", "Remove from my collection");
22
23 string currentUrl = SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?ID=" + GetGlobalValue("Global:Page.ID")); // works
24
25 string collectionName = Dynamicweb.Context.Current.Request.QueryString.Get("collection");
26
27 string designBaseUrl = GetString("Template:DesignBaseUrl");
28
29 string userId = Dynamicweb.Frontend.PageView.Current().User.ID.ToString();
30
31 string contactUsLink = HagsWeb.Library.Utilities.DWUtilities.GetPageByNavigationTag("ContactUs", currentPage);
32
33 @*
34 API hints:
35 @Dynamicweb.Frontend.PageView.Current().Area.ID
36 @Dynamicweb.Frontend.PageView.Current().User.ID
37 *@
38
39 string productListHtml = "";
40 string downloadButtons = "";
41
42 string catalogueName = "";
43 string catalogueDescription = "";
44 string catalogueType = "";
45
46 int collectionStatus = 0;
47
48 Dynamicweb.Frontend.PageView thisPage = Dynamicweb.Frontend.PageView.Current();
49 if ( !string.IsNullOrEmpty(collectionName) )
50 {
51 AjaxProductCollection productCollection = HagsCustomModules.Ajax.UsersProductCollection.UsersProductCollection.GetCollectionFromXml(userId, collectionName, collectionPage.Area);
52
53
54 productListHtml = productCollection.Html;
55 downloadButtons = productCollection.DownloadButtons;
56
57 if ( productCollection.CatalogueCollectionList != null )
58 {
59 CatalogueCollection catalogue = productCollection.CatalogueCollectionList.FirstOrDefault();
60 catalogueName = catalogue.CollectionName;
61 catalogueDescription = catalogue.CollectionDescription;
62 catalogueType = catalogue.CollectionType;
63
64 string editCollectionPrompt = productCollection.Message;
65 int ProductCollectionCount = productCollection.ProductCount;
66 }
67
68 collectionStatus = productCollection.Status;
69
70 }
71
72 string deleteCollectionData = "All," + catalogueName.Replace("'", "'") + "," + userId;
73
74 //Read all collections from all XML files if all are required
75 List<CatalogueCollection> MyHagsCatalogueCollections = new List<CatalogueCollection>();
76 if (string.IsNullOrEmpty(collectionName))
77 {
78 MyHagsCatalogueCollections = HagsCustomModules.Ajax.UsersProductCollection.UsersProductCollection.ReadCollectionsFromXml(@GetGlobalValue("Global:Extranet.UserID"), GetGlobalValue("Global:Area.Culture.Name"));
79 }
80
81 List<ProductCollectionItem> productCollectionItems = SessionManager.UsersMyProductCollection != null ? SessionManager.UsersMyProductCollection : new List<ProductCollectionItem>();
82 }
83
84 <!--/HagsModules/MyHags/MyHagsProductCollection.cshtml-->
85
86 @*@Scripts.Render("~/bundle/ProductFilter")*@
87 @*@Scripts.Render("~/bundle/AssetSearch")*@
88
89
90 @{
91 string legacyHeading = GetString("Item.Display_Heading");
92 string legacyContent = GetString("Item.Content");
93 string mainHeading = GetString("Item.Heading");
94 string mainCopy = GetString("Item.Main_Copy");
95
96 string collectionTitle = catalogueName != "" ? ": <span id=\"js-cat-title\">" + catalogueName : "</span>";
97 string useHeading = legacyHeading == "" ? mainHeading : legacyHeading;
98 string useCopy = legacyContent == "" ? mainCopy : legacyContent;
99 }
100
101
102 <nav class="connect-nav">
103
104 <div class="wrapper">
105
106 @RenderNavigation(new{
107 ParentTag = "MyHags",
108 Template = "simple-nav-page.xslt"
109 })
110
111 </div>
112
113 </nav>
114
115 <section>
116 <div class="center-copy flow">
117 <h1 class="ts-4">@(useHeading + collectionTitle)</h1>
118 @useCopy
119 </div>
120 </section>
121
122
123 @if (!string.IsNullOrEmpty(collectionName))
124 {
125
126 if ( collectionStatus > 0 )
127 {
128 <div class="wrapper">
129 <div class="collection__ui ui-with-sidebar">
130 <div class="sidebar flow-s">
131
132 <div class="cluster">
133
134
135 <a href="@currentUrl" class="btn btn--info">
136 @Translate("Return to collections", "Return to your collections")
137 </a>
138
139
140 <button class="btn btn--outline" type="button" name="download" data-parent="Bilder" data-productnumber="" data-productname="">
141 @Translate("DownloadImages", "Download Images")
142 </button>
143
144 <button class="btn btn--outline" type="button" name="download" data-parent="Ritningar" data-productnumber="" data-productname="">
145 @Translate("DownloadDWGFiles", "Download DWG Files")
146 </button>
147
148 <button class="btn btn--outline" type="button" name="download" data-parent="Monteringsanvisningar" data-productnumber="" data-productname="">
149 @Translate("InstallationGuides", "Installation Guides")
150 </button>
151
152 @if (!string.IsNullOrEmpty(contactUsLink))
153 {
154 <a class="btn btn--outline" href="@(contactUsLink)/quote" role="button" data-parent="#quickquote">
155 @Translate("CreateQuickQuote", "Create a Quick Quote")
156 </a>
157 }
158
159 <button class="btn btn--outline" data-toggle="modal" data-target="#CreateCatalog" data-shout="@printShout" Name="catalogPublishing" role="button" data-parent="#catalogue">
160 @Translate("CreateYourCatalog", "Create Your Catalogue")
161 </button>
162
163 </div>
164
165
166 @*
167 <div id="accordion" role="tablist" aria-multiselectable="false">
168 @downloadButtons
169 </div>
170 *@
171
172 <div id="collectiondetails" class="flow-xs">
173
174 <h6>@Translate("Collection Details", "Collection details"):</h6>
175
176 <div class="details-read flow-xs">
177 <div class="collection-info flow-xs">
178 <p><b>@Translate("Name", "Name"):</b><br /><span id="js-cat-name">@catalogueName</span></p>
179 <p><b>@Translate("CollectionDescription", "Description"):</b><br /><span id="js-cat-desc">@catalogueDescription</span></p>
180 </div>
181 <button class="btn btn--outline" onclick="javascript:editCustomCatalogue();return false;">
182 @Translate("Edit", "Edit")
183 </button>
184 <!--<button onclick="javascript:copyCustomCatalogue();return false;" itemprop="Copy Collection" class="btn btn--outline">
185 @Translate("Copy collection", "Copy this Collection")
186 </button>-->
187 <button onclick="javascript:deleteCustomCatalogue();return false;" class="btn btn--warn" itemprop="Delete Collection" data-deletecollection="@deleteCollectionData">
188 @Translate("Delete collection", "Delete this Collection")
189 </button>
190 <div id="details-advice"></div>
191 </div>
192
193 <div class="details-edit hide">
194
195 <form role="form" method="post" id="updateCollectionForm" action="">
196
197 <input type="hidden" name="UserId" value="@userId">
198 <input type="hidden" name="OriginalFileName" value="@catalogueName">
199 <input type="hidden" name="Culture" value="@collectionArea.Culture">
200 <div class="flow-xs">
201 <div class="form-group">
202 <label for="collectionName" class="control-label">@Translate("Name", "Name"): <sup>*</sup></label>
203 <input type="text" class="form-control" name="CollectionName" value="@catalogueName" required>
204 </div>
205
206 <div class="form-group">
207 <label for="collectionDescription" class="control-label">@Translate("CollectionDescription", "Description"): <sup>*</sup></label>
208 <textarea type="text" class="form-control" rows="4" cols="50" name="CollectionDescription" required>@catalogueDescription</textarea>
209 </div>
210
211 <button type="submit" name="updatecollection" class="btn btn--outline">@Translate("Save", "Save")</button>
212 </div>
213
214 </form>
215
216 </div>
217
218 <div id="resultAdvice" class="hide"></div>
219
220 </div>
221
222
223
224 </div> <!-- end sideber -->
225
226 <div class="main">
227
228 @*<h3 class="ts-3">@catalogueName</h3>*@
229
230 <div class="products-listing__grid products-listing__grid--small" id="prods_MyProductCollection">
231
232 @if (productCollectionItems.Any())
233 {
234
235 foreach (ProductCollectionItem item in productCollectionItems)
236 {
237 <div class="product-card collection__item">
238
239 <div class="product-card__actions in-collection">
240
241 <button type="button" class="action-btn" data-removeProductlist="@(item.ProductNumber)" data-update-filename="@collectionName" data-user="@userId">
242 <span class="visually-hidden">@removeCopy</span>
243 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 212 212" class="h24-icon h24-icon--minus"><path fill="currentColor" fill-rule="evenodd" d="M106 6c55.193 0 100 44.807 100 100s-44.807 100-100 100S6 161.193 6 106 50.807 6 106 6Zm0 5.333c-26.124 0-49.792 10.603-66.928 27.74C21.936 56.207 11.333 79.875 11.333 106c0 26.124 10.603 49.792 27.74 66.928 17.135 17.136 40.803 27.739 66.927 27.739 26.124 0 49.792-10.603 66.928-27.74 17.136-17.135 27.739-40.803 27.739-66.927 0-26.124-10.603-49.792-27.74-66.928C155.793 21.936 132.125 11.333 106 11.333Zm28.772 87.504a6.5 6.5 0 0 1 6.5 6.5v1a6.5 6.5 0 0 1-6.5 6.5h-57a6.5 6.5 0 0 1-6.5-6.5v-1a6.5 6.5 0 0 1 6.5-6.5h57Z"/></svg>
244 </button>
245
246 </div>
247
248 <div class="product-card__img-silo">
249
250 @if (item.ProductImageUrl != null && !String.IsNullOrEmpty(item.ProductUrlReference))
251 {
252 <a href="@item.ProductUrlReference">
253 <img src="@item.ProductImageUrl" class="product-card__img" />
254 </a>
255 }
256 else
257 {
258 <a href="@item.ProductUrlReference" class="product-card__missing">
259 <img src="@(designBaseUrl)assets/img/h24-see-saw.svg">
260 <span>No Image Available</span>
261 </a>
262 }
263
264 </div>
265
266 <div class="product-card__copy">
267
268 <p class="product-card__heading">
269 <a href="@item.ProductUrlReference">@(item.ProductName)</a>
270 </p>
271
272 <p>@item.ProductNumber</p>
273
274 @if (!string.IsNullOrEmpty(item.ProductVariantId))
275 {
276 Tuple<string, string, string, string, string, string, List<VariantOption>> optionsTuple = ProductFieldValues.GetProductOptions(item.ProductVariantId, collectionArea.EcomLanguageId);
277
278 //optionsTuple.Item1; "Red"
279 //optionsTuple.Item2; "Above Ground"
280 //optionsTuple.Item3; "Wooden Post"
281 //optionsTuple.Item4; "Wooden Post / HPL Panels"
282 //optionsTuple.Item5; "A310.png"
283 //optionsTuple.Item6; "A310-diagram.png"
284 //optionsTuple.Item7; List<VariantOption> Not used here
285
286 <div class="product-icon ts--1">
287 <img src="/Files/Templates/Designs/HagsCore/res/img/icons/anchoring/@optionsTuple.Item5" alt="@optionsTuple.Item2">
288 @optionsTuple.Item2
289 </div>
290
291 }
292
293 </div>
294
295 </div>
296 }
297
298 }
299 </div>
300
301 </div> <!-- end main -->
302 </div>
303 </div>
304 }
305 else
306 {
307 <div class="wrapper">
308 <h1 class="ts-4">Product Collection:</h1>
309 <p>Collection not found, it may have been deleted.</p>
310 </div>
311
312 }
313
314 }
315
316 <div class="wrapper">
317
318
319 <!--List of Collections-->
320 @if (MyHagsCatalogueCollections.Count > 0)
321 {
322
323 <div class="attractor-panels">
324
325 <!--If we have some MyHags Catalogue collections-->
326 @foreach (CatalogueCollection collection in MyHagsCatalogueCollections)
327 {
328 string link = currentUrl + "?collection=" + collection.CollectionName.Replace(" ", "-");
329
330 <div class="card">
331 <div class="card__core">
332
333 @foreach (var a in collection.CatalogueItems.Take(1))
334 {
335 string file = a.ProductNumber + ".jpg";
336 <img src="/Assets/@a.ProductNumber/bilder/thumb_@file">
337
338 }
339
340 @foreach (var a in collection.CatalogueItems.Skip(1).Take(1))
341 {
342 string file = a.ProductNumber + ".jpg";
343 <img src="/Assets/@a.ProductNumber/bilder/thumb_@file">
344 }
345
346 </div>
347
348 <div class="card__copy-extra flow-xs">
349
350 <h4 class="ts-2">
351 @collection.CollectionName.Replace("-", " ")
352 </h4>
353
354 <p>@collection.CollectionDescription</p>
355
356 <p class="ts--1">@collection.CreationDate</p>
357
358 <p><a href="@link" role="button" class="btn btn--outline">@Translate("View Collection", "View Collection")</a></p>
359
360 </div>
361
362 </div>
363 }
364 </div>
365
366 }
367 else if (MyHagsCatalogueCollections.Count == 0 && string.IsNullOrEmpty(collectionName))
368 {
369 @GetString("ParagraphContent")
370 }
371
372 </div>
373