Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sonja 133 posts 621 karma points
    Mar 22, 2019 @ 05:40
    Sonja
    0

    Getting values for created property types in members

    Hi,

    For the certain Members I have created properties like

                var mts = Services.MemberTypeService;
                var mt = mts.Get("Member");
                var groups = mt.PropertyGroups;
                if (!groups.Any(x => x.Name == "Details"))
                {
                    mt.AddPropertyGroup("Details");
                }
                CreatePropertyTypeIfNotExists(mt, "IDNumber");
                CreatePropertyTypeIfNotExists(mt, "FirstName");
                CreatePropertyTypeIfNotExists(mt, "LastName");
                CreatePropertyTypeIfNotExists(mt, "ContactNumber");
                CreatePropertyTypeIfNotExists(mt, "AlternateContactNumber");
                CreatePropertyTypeIfNotExists(mt, "Address");
                CreatePropertyTypeIfNotExists(mt, "AddressCity");
                CreatePropertyTypeIfNotExists(mt, "Province");
                CreatePropertyTypeIfNotExists(mt, "PostalCode");   
                mts.Save(mt);
    

    Then I'm inserting the values:

    var memberService = Services.MemberService;
    
                var m2 = memberService.GetByUsername(model.CreateUsername);
                m2.Properties["IDNumber"].Value = model.IDNumber;
                m2.Properties["FirstName"].Value = model.FirstName;
                m2.Properties["LastName"].Value = model.LastName;
                m2.Properties["ContactNumber"].Value = model.ContactNumber;
                m2.Properties["AlternateContactNumber"].Value = model.AlternateContactNumber;
                m2.Properties["Address"].Value = model.Address;
                m2.Properties["Province"].Value = model.Province;
                m2.Properties["PostalCode"].Value = model.PostalCode;
                m2.Properties["AddressCity"].Value = model.AddressCity;
                m2.Properties["Province"].Value = model.Province;
                m2.Properties["PostalCode"].Value = model.PostalCode;
    
                memberService.Save(m2);
    

    now in Razor I would like to take those properties. I have like

      var mid = Members.GetCurrentMember();
    

    How do I get rest of the address?

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Mar 22, 2019 @ 08:39
    Alex Skrypnyk
    100

    Hi Sonja

    Use "GetPropertyValue" method.

    var mid = Members.GetCurrentMember();
    var IDNumber = mid.GetPropertyValue("IDNumber");
    

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft