Extend widget not fully possible for Profile widget - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Extend widget not fully possible for Profile widget

  • Extend widget not fully possible for Profile widget
  • I was following the following link docs.sitefinity.com/feather-extend-the-navigation-widget-model
    Because I need some extra attributes on the profile page to be saved to a custom database but I noticed most methods on the models are not marked as virtual so I can not override them use my custom implementation is this intended?

    Example code:

    PortalProfileModel

    public class PortalProfileModel : ProfileModel
        public PortalProfileModel() : base()
        
     
        
     
        public ProfilePreviewViewModel GetProfilePreviewViewModel()
        
            if (this.SelectedUserProfiles == null || this.SelectedUserProfiles.Count == 0)
                return null;
     
            var viewModel = new PortalProfilePreviewViewModel(this.SelectedUserProfiles)
            
                CssClass = this.CssClass,
                CanEdit = this.CanEdit()
            ;
     
            return viewModel;
        

    PortalProfilePreviewViewModel

    public class PortalProfilePreviewViewModel: ProfilePreviewViewModel
       
           /// <summary>
           /// Initializes a new instance of the <see cref="ProfilePreviewViewModel"/> class.
           /// </summary>
           public PortalProfilePreviewViewModel() : base()
           
           
     
           /// <summary>
           /// Initializes a new instance of the <see cref="ProfilePreviewViewModel"/> class.
           /// </summary>
           /// <param name="userProfile">The user profile.</param>
           public PortalProfilePreviewViewModel(IList<UserProfile> userProfiles) : base(userProfiles)
           
               if (userProfiles != null && userProfiles.Count() > 0)
               
                   this.InitializeUserRelatedData(userProfiles.First().User);
               
           
     
           public bool MailBinEmptiedNotification get; set;
           public bool MailDoorOpenNotification get; set;
           public bool MailHatchOpenNotification get; set;
           public bool MailBinIsFullNotification get; set;
           public bool MailBinAlmostFullNotification get; set;
     
           /// <summary>
           /// Initializes the user related data.
           /// </summary>
           /// <param name="user">The user.</param>
           private void InitializeUserRelatedData(User user)
           
               MailBinAlmostFullNotification = true;
               MailDoorOpenNotification = true;
           
       

    Read.ProfilePreview.cshtml

    @model ECOnXWebApp.Mvc.Models.Profile.PortalProfilePreviewViewModel
    @using Telerik.Sitefinity.Frontend.Identity.Mvc.Models.Profile;
    @using Telerik.Sitefinity.Frontend.Mvc.Helpers;
     
    <div class="@Model.CssClass">
        <form class="form-horizontal col-sm-10">
            <div class="row">
                <h3>@Model.DisplayName</h3>
                <p>@Model.Email</p>
     
                <div class="form-group">
                    <label class="control-label col-sm-3" for="email">Mail almost full notification</label>
                    <div class="col-sm-8">
                        <div class="checkbox">
                            <label><input type="checkbox">@Model.MailBinAlmostFullNotification</label>
                        </div>
                    </div>
                </div>
                @if (Model.CanEdit && ViewBag.Mode == ViewMode.Both)
                
                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-8">
                            @Html.ActionLink(Html.Resource("EditProfileLink"), "EditProfile");
                        </div>
                    </div>
                
            </div>
     
    </form>
    </div>

     

    Global.asax

    protected void Application_Start(object sender, EventArgs e)
        Bootstrapper.Initialized += this.Bootstrapper_Initialized;
     
    private void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
        if (e.CommandName == "Bootstrapped")
        
            FrontendModule.Current.DependencyResolver.Rebind<IProfileModel>().To<PortalProfileModel>();
        

     

    I get exceptions because my GetProfilePreviewViewModel() never gets called (with or without new keyword.