-
Notifications
You must be signed in to change notification settings - Fork 4
7.2 Updating custom properties
Theo Paraskevopoulos edited this page Oct 15, 2016
·
2 revisions
##Updating custom properties
Among others, this feature can be useful for letting users manage their profile information. The code below will display and save custom properties for a Member linked to a Contact.
@using PipelineCRM.Services;
@using PipelineCRM.Models;
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "Members.cshtml";
// Get current member
var member = Membership.GetUser();
if (member == null)
{
Response.Redirect("/");
}
// Call the Pipeline service to get the Contact
var contactService = new ContactService();
var contact = contactService.GetByEmail(member.Email);
if (contact != null && IsPost)
{
// Create a new dictionary with new properties
var customProps = new Dictionary<string, dynamic>()
{
{"dob", Request["dob"]},
{"favouriteColour", Request["favouriteColour"]},
{"twitterHandler", Request["twitterHandler"]}
};
// Update and Save
contact.UpdateProperties(customProps).Save();
<div class="card green darken-2">
<div class="card-content white-text">Your changes have been saved.</div>
</div>
}
<div class="row">
<form class="col s12" method="post">
<div class="row">
<div class="input-field col s12">
<label>DOB</label>
<input type="text" name="dob" placeholder="Date of birth" value="@contact.GetPropertyValue("dob")" />
</div>
</div>
<div class="row">
<div class="input-field col s12">
<label>Favourite colour</label>
<input type="text" name="favouriteColour" placeholder="E.g. blue" value="@contact.GetPropertyValue("favouriteColour")" />
</div>
</div>
<div class="row">
<div class="input-field col s12">
<label>Twitter handler</label>
<input type="text" name="twitterHandler" placeholder="E.g. @("@bob")" value="@contact.GetPropertyValue("twitterHandler")" />
</div>
</div>
<button class="btn waves-effect waves-light">Save</button>
</form>
</div>
}