Manage Account
Exception in template (Designs\Denville\AlencastreTools/impersonate.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.accaddbbfeccdb.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using System; @using System.Linq; @using Dynamicweb.Rendering; @using Dynamicweb.Modules.UserManagement; @{ Pageview.Meta.Title = Translate("manageAccount", "Manage Account"); var item = Pageview.Area.Item; UserCollection users = String.IsNullOrWhiteSpace(Pageview.User.SecondaryUserID.ToString()) ? User.GetCurrentUser().GetUsersICanSetAsSecondary() : User.GetUserByID(Pageview.User.SecondaryUserUserID).GetUsersICanSetAsSecondary(); //UserCollection users = String.IsNullOrWhiteSpace(Pageview.User.SecondaryUserID.ToString()) ? DenvilleQuotes.Account.Impersonate.GetUsersICanSetAsSecondary() : DenvilleQuotes.Account.Impersonate.GetUsersICanSetAsSecondary(Pageview.User.SecondaryUserUserID); if (users.Any()) { if (String.IsNullOrWhiteSpace(Pageview.User.SecondaryUserID.ToString())) { <h2>@Translate("ChooseTheUserYouWishToManage:", "Choose the user you wish to manage"):</h2> } <form class="DMForms" data-error='@Translate("thatAccountDoesNotExist", "That account does not exist.")' id="impersonateForm" method="post" action="/"> <input type="hidden" name="ID" value="@(item["AccountInformation"].ToString().Replace("Default.aspx?ID=", ""))" /> <input type="hidden" id="DWExtranetSecondaryUserSelector" name="DWExtranetSecondaryUserSelector" /> @if (String.IsNullOrWhiteSpace(Pageview.User.SecondaryUserID.ToString())) { <div class="form-fields row"> <fieldset class="mandatory col-md-8 col-xs-12 noPadding"> <label class="hide">@Translate("ChooseTheUserYouWishToManage:", "Choose the user you wish to manage")</label> <input type="text" id="DWExtranetSecondaryUser" name="DWExtranetSecondaryUser" /> </fieldset> </div> } <div class="row"> <div class="formButtons col-sm-4 col-xs-12"> @if (String.IsNullOrWhiteSpace(Pageview.User.SecondaryUserID.ToString())) { <input type="submit" class="btn btn-primary pull-left" value="@Translate("manage","Manage")" /> } else { <a href="javascript:void(0);" class="pull-left btn btn-default leftPadding">@Translate("Return to my primary account")</a> } </div> </div> </form> <form id="removeSecondaryUserForm" class="hidden" method="post" action="@Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(Pageview.Page.ID)"> <input type="hidden" name="DwExtranetRemoveSecondaryUser" value="1" /> </form> } else { <p>@Translate("You can't select an account, please contact us.")</p> } } @SnippetStart("jsOnLoad") var obj_autoCompleteAjax = []; @foreach (User user in users.GroupBy(u => u.ID).Select(grp => grp.First()).OrderBy(u => u.Company)) { string userName = !string.IsNullOrWhiteSpace(user.Name) ? user.Name : user.FirstName + " " + user.LastName, fullName = user.Company + " - " + userName + " - " + user.CustomerNumber; <text> obj_autoCompleteAjax.push({ value:'@user.ID', label: "@fullName" }); </text> } onLoadImpersonation(obj_autoCompleteAjax); @SnippetEnd("jsOnLoad")