Gestisci Account

Exception in template (Designs\USKidsGolf\TemplateRenderer/ManageAccounts.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.dacccdacffbf.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits RazorTemplateBase<RazorTemplateModel<Template>> @using System @using System.Collections.Generic @using System.Linq @using Dynamicweb.Rendering; @using Dynamicweb.Security.UserManagement @functions{ const string pageParameter = "PageNum"; const int pageSize = 30; int currentPage = 1; int totalPages = 1; string searchedTerms = ""; } @{ searchedTerms = (System.Web.HttpContext.Current.Request["s"] ?? "").ToString().ToLower(); var showSetDefaultAccount = false; bool.TryParse((Pageview.Area.Item[Dna.AutoImpersonate.Constants.AreaSettings.ShowDefaultAccount] ?? "").ToString(), out showSetDefaultAccount); var managePageAjax = 0; int.TryParse((Pageview.Area.Item[Dna.AutoImpersonate.Constants.AreaSettings.ManageAccountsAjax] ?? "").ToString(), out managePageAjax); managePageAjax = managePageAjax > 0 ? managePageAjax : Pageview.Page.ID; var stopImpersonateAjaxUrl = string.Format("/Default.aspx?Id={0}&DwExtranetRemoveSecondaryUser=1", managePageAjax); var loginUser = Pageview.User.CurrentSecondaryUser != null ? Pageview.User.CurrentSecondaryUser : Pageview.User; var impersonateUsers = UsKidsGolf.AutoImpersonationExtender.Helper.ReadUserForimpersonate(loginUser, Pageview) ?? new List<User>(); var errors = System.Web.HttpContext.Current.Request[Dna.AutoImpersonate.Constants.Parameters.RequireManaging] != null ? Translate("selectAccountToManage", "Please select an account to manage before continuing") : string.Empty; if (!string.IsNullOrEmpty(searchedTerms)) { impersonateUsers = impersonateUsers.Where(u => u.FirstName.ToLower().Contains(searchedTerms) || u.LastName.ToLower().Contains(searchedTerms) || u.Name.ToLower().Contains(searchedTerms) || u.CustomerNumber.ToLower().Contains(searchedTerms)); } var showStopBtn = loginUser.CustomFieldValues.FirstOrDefault(cf => cf.CustomField.SystemName.Equals(Dna.AutoImpersonate.Constants.CustomFields.ForceImpersonationSetting)).Value.Equals(Dna.AutoImpersonate.Constants.CustomFields.Options.UserNeverImpersonate); var hasUsers = false; var impersonateUsersCount = impersonateUsers.Count(); int.TryParse(System.Web.HttpContext.Current.Request[pageParameter], out currentPage); currentPage = currentPage > 1 ? currentPage : 1; var skipUsers = (currentPage - 1) * pageSize; totalPages = (int) Math.Ceiling((decimal) impersonateUsersCount / pageSize); } <div class="row"> <p class="col-xs-12 col-sm-6"> @Translate("manageAccountsIntro", "Click Manage Account to work with desired account.") </p> @if (impersonateUsersCount > 10 || !string.IsNullOrEmpty(searchedTerms)) { <form class="col-xs-12 col-sm-3 col-sm-offset-3 DMForms" action="/Default.aspx" id="searchUsersForm" class="form-inline"> <input type="hidden" name="ID" value='@Pageview.Page.ID'> <fieldset class="col-xs-12 TextInput noPadding"> <input placeholder='@Translate("searchCustomer", "Search customer")' type="text" name="s" value="@searchedTerms"/> </fieldset> <button type="submit" class="btn pull-right"> <i class="fa fa-search"></i> </button> </form> } </div> <table id="switchAccount" class="col-xs-12 noPadding-xs noPadding-sm dataTable"> <colgroup> <col siz width="10%"/> <col width="25%"/> <col width="10%"/> <col width="10%"/> <col width="10%"/> <col width="15%"/> <col width="10%"/> </colgroup> <thead> <tr> <th>@Translate("customer#", "Customer No.")</th> <th>@Translate("companyName", "Company Name")</th> <th>@Translate("city", "City")</th> <th>@Translate("zip", "Zip")</th> <th>@Translate("state", "State")</th> <th>@Translate("paymentTerms", "Payment Terms")</th> <th>&nbsp;</th> </tr> </thead> <tbody> @foreach (var user in impersonateUsers.OrderBy(u => u.Name).Skip(skipUsers).Take(pageSize)) { hasUsers = true; var userImpersonateUrl = string.Format("/Default.aspx?Id={0}&DWExtranetSecondaryUserSelector={1}&{2}={3}", Pageview.Page.ID, user.ID, pageParameter, currentPage); var isImpersonatedUser = user.ID == Pageview.User.ID; var paymentTermsField = user.CustomFieldValues.Find(cf => cf.CustomField.SystemName.Equals("AccessUser_PaymentTerms")); var userStopImpersonateAjaxUrl = string.Format("{0}&DefaultAccount={1}", stopImpersonateAjaxUrl, user.ID); <tr> <td data-th="@(Translate("customer#", "Customer No."))">@user.CustomerNumber.Replace("ItalyCustomer-IT_","")</td> <td data-th="@(Translate("companyName", "Company Name"))">@user.Name</td> <td data-th="@(Translate("city", "City"))">@user.City</td> <td data-th="@(Translate("zip", "Zip"))">@user.Zip</td> <td data-th="@(Translate("state", "State"))">@user.State</td> <td data-th="@(Translate("paymentTerms", "Payment Terms"))">@String.Format("{0}", paymentTermsField != null ? paymentTermsField.Value.ToString() : string.Empty)</td> <td class="actions text-right"> @if (isImpersonatedUser) { if (showStopBtn) { <a href="@(string.Format("/Default.aspx?Id={0}&DwExtranetRemoveSecondaryUser=1&{1}={2}", Pageview.Page.ID, pageParameter, currentPage))" class="btn btn-outline">@Translate("stopManageAccount", "Stop")</a> } else { <a disabled="disabled" class="btn btn-outline">@Translate("managingAccount", "Managing Account")</a> } } else { <a href="@userImpersonateUrl" action="@userStopImpersonateAjaxUrl" class="selectAccount btn btn-bg">@Translate("manageAccount", "Manage Account")</a> } @if (showSetDefaultAccount) { if (Dna.AutoImpersonate.Helpers.ReadDefaultId(loginUser) == user.ID.ToString()) { <a href="javascript:void(0);" class="btn btn-outline">@Translate("defaultAccount", "Default Account")</a> } else { <a href="@(string.Format("/Default.aspx?Id={0}&DefaultAccount={1}", managePageAjax, user.ID))" class="setDefaultAccount btn btn-bg">@Translate("setDefaultAccount", "Set Default Account")</a> } } </td> </tr> } @if (!hasUsers) { <tr> <td>No Accounts</td> </tr> } </tbody> </table> @RenderPagination() @SnippetStart("jsOnLoad") onLoadSwitchAccount("@errors"); @SnippetEnd("jsOnLoad") @helper RenderPagination() { var loopPageSize = 3; var newPageBaseUrl = string.Format("/Default.aspx?Id={0}", Pageview.Page.ID); if (!string.IsNullOrEmpty(searchedTerms)) { newPageBaseUrl += "&s=" + searchedTerms; } newPageBaseUrl += string.Format("&{0}=", pageParameter); if (totalPages > 1) { var active = ""; int thisPage = 0; var startPage = 1; var endPage = totalPages; var pageOffset = Math.Floor(Convert.ToDecimal(loopPageSize / 2)); var middlePage = pageOffset + 1; if (totalPages > loopPageSize) { startPage = (Convert.ToInt32(currentPage - pageOffset) < 1) ? 1 : Convert.ToInt32(currentPage - pageOffset); endPage = (Convert.ToInt32(currentPage + pageOffset) > totalPages) ? totalPages : Convert.ToInt32(currentPage + pageOffset); if (currentPage < middlePage) { endPage = loopPageSize; } else if (currentPage > middlePage) { if (totalPages < (currentPage + pageOffset)) { startPage = totalPages - loopPageSize; if (loopPageSize % 2 != 0) { startPage += 1; } } if (loopPageSize % 2 == 0) { startPage += 1; } } } <div class="footerBox col-xs-12"> <ul class="pagination"> @if (currentPage > 1) { @PageItem(0, (newPageBaseUrl + (currentPage - 1)), "&laquo; " + Translate("previous", "Previous") + " ") } @if (currentPage > 2 && totalPages > 3) { @PageItem(1, (newPageBaseUrl + 1), "1") @Ellipsis() } @for (var i = startPage; i <= endPage; i++) { @PageItem(i, (newPageBaseUrl + i), i.ToString()) } @if (currentPage < totalPages - 1 && totalPages > 3) { @Ellipsis() @PageItem(totalPages, (newPageBaseUrl + totalPages), totalPages.ToString()) } @if (currentPage < totalPages) { @PageItem(0, (newPageBaseUrl + (currentPage + 1)), " " + Translate("next", "Next") + " &raquo;") } </ul> </div> } } @helper PageItem(int pageNum, string href, string text) { var liClass = currentPage == pageNum ? "class=\"active\"" : ""; <li @liClass> <a href="@href">@text</a> </li> } @helper Ellipsis() { <li> <span>...</span> </li> }

LA NOSTRA MISSIONE

La missione della U.S. Kids Golf e' favorire il divertimento dei bambini insegnando loro "il gioco della vita" che e' il golf e incoraggiare l'interazione con la propria famiglia affinche' si costruiscano ricordi indelebili