Skip to content

Instantly share code, notes, and snippets.

@pynej
Last active November 1, 2016 18:16
Model Partials for Relator
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Persistence;
namespace ProjectNamespace.Models.Generated
{
public partial class ShopMarket
{
[ResultColumn, JsonIgnore] // JsonIgnore if included means that the child data from this column wont be serialised and send down to Angualr.
public List<ShopZipcode> ShopZipcode { get; set; }
[ResultColumn]
public List<ShopMarketService> ShopMarketService { get; set; }
// Example helper method using related models.
public string PrimaryZipCode
{
get
{
if (ShopZipcode != null && ShopZipcode.Where(s => s.IsPrimary).Count() > 0)
return ShopZipcode.FirstOrDefault(s => s.IsPrimary).ZipCode;
else
return "";
}
}
}
}
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Persistence;
namespace ProjectNamespace.Models.Generated
{
public partial class ShopMarketService
{
public ShopService ShopService { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment