public static PlatformAmount GetSingleOrNewPlatformAmount(this DbContext context, PlatformAmountType amountType) { var model = context.Set <PlatformAmount>().Where(m => m.AmountType == amountType).FirstOrDefault(); if (model == null) { model = new PlatformAmount { Amount = 0, AmountType = amountType }; context.AddToPlatformAmount(model); } return(model); }
public static PlatformAmount AddToPlatformAmount(this DbContext context, PlatformAmount model) { context.Set <PlatformAmount>().Add(model); return(model); }