示例#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);
        }
示例#2
0
 public static PlatformAmount AddToPlatformAmount(this DbContext context, PlatformAmount model)
 {
     context.Set <PlatformAmount>().Add(model);
     return(model);
 }