예제 #1
0
        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);
        }