public void Save(AuthContext context) { if (saveMask == AccountCurrencySaveMask.None) { return; } var model = new AccountCurrencyModel { Id = accountId, CurrencyId = (byte)CurrencyId, Amount = Amount }; if ((saveMask & AccountCurrencySaveMask.Create) != 0) { context.Add(model); } else if ((saveMask & AccountCurrencySaveMask.Amount) != 0) { EntityEntry <AccountCurrencyModel> entity = context.Attach(model); entity.Property(p => p.Amount).IsModified = true; } saveMask = AccountCurrencySaveMask.None; }
public void Save(AuthContext context) { if (saveMask == SaveMask.None) { return; } var model = new AccountEntitlementModel { Id = accountId, EntitlementId = (byte)Type, Amount = amount }; if ((saveMask & SaveMask.Create) != 0) { context.Add(model); } else { EntityEntry <AccountEntitlementModel> entity = context.Attach(model); entity.Property(p => p.Amount).IsModified = true; } saveMask = SaveMask.None; }
/// <summary> /// Update <see cref="Account"/> with supplied session key asynchronously. /// </summary> public static async Task UpdateAccountSessionKey(Account account, byte[] sessionKeyBytes) { account.SessionKey = BitConverter.ToString(sessionKeyBytes).Replace("-", ""); using (var context = new AuthContext()) { EntityEntry <Account> entity = context.Attach(account); entity.Property(p => p.SessionKey).IsModified = true; await context.SaveChangesAsync(); } }
/// <summary> /// Update <see cref="Account"/> with supplied game token asynchronously. /// </summary> public static async Task UpdateAccountGameToken(Account account, Guid guid) { account.GameToken = guid.ToByteArray().ToHexString(); using (var context = new AuthContext()) { EntityEntry <Account> entity = context.Attach(account); entity.Property(p => p.GameToken).IsModified = true; await context.SaveChangesAsync(); } }
public void Save(AuthContext context) { if ((saveMask & BindingSaveMask.Create) != 0) { var model = new AccountKeybinding { Id = (uint)Owner, InputActionId = InputActionId, DeviceEnum00 = DeviceEnum00, DeviceEnum01 = DeviceEnum01, DeviceEnum02 = DeviceEnum02, Code00 = Code00, Code01 = Code01, Code02 = Code02, MetaKeys00 = MetaKeys00, MetaKeys01 = MetaKeys01, MetaKeys02 = MetaKeys02, EventTypeEnum00 = EventTypeEnum00, EventTypeEnum01 = EventTypeEnum01, EventTypeEnum02 = EventTypeEnum02 }; context.Add(model); } else { var model = new AccountKeybinding { Id = (uint)Owner, InputActionId = InputActionId }; if ((saveMask & BindingSaveMask.Delete) != 0) { context.Entry(model).State = EntityState.Deleted; } else { EntityEntry <AccountKeybinding> entity = context.Attach(model); if ((saveMask & BindingSaveMask.DeviceEnum00) != 0) { model.DeviceEnum00 = DeviceEnum00; entity.Property(p => p.DeviceEnum00).IsModified = true; } if ((saveMask & BindingSaveMask.DeviceEnum01) != 0) { model.DeviceEnum01 = DeviceEnum01; entity.Property(p => p.DeviceEnum01).IsModified = true; } if ((saveMask & BindingSaveMask.DeviceEnum02) != 0) { model.DeviceEnum02 = DeviceEnum02; entity.Property(p => p.DeviceEnum02).IsModified = true; } if ((saveMask & BindingSaveMask.Code00) != 0) { model.Code00 = Code00; entity.Property(p => p.Code00).IsModified = true; } if ((saveMask & BindingSaveMask.Code01) != 0) { model.Code01 = Code01; entity.Property(p => p.Code01).IsModified = true; } if ((saveMask & BindingSaveMask.Code02) != 0) { model.Code02 = Code02; entity.Property(p => p.Code02).IsModified = true; } if ((saveMask & BindingSaveMask.MetaKeys00) != 0) { model.MetaKeys00 = MetaKeys00; entity.Property(p => p.MetaKeys00).IsModified = true; } if ((saveMask & BindingSaveMask.MetaKeys01) != 0) { model.MetaKeys01 = MetaKeys01; entity.Property(p => p.MetaKeys01).IsModified = true; } if ((saveMask & BindingSaveMask.MetaKeys02) != 0) { model.MetaKeys02 = MetaKeys02; entity.Property(p => p.MetaKeys02).IsModified = true; } if ((saveMask & BindingSaveMask.EventTypeEnum00) != 0) { model.EventTypeEnum00 = EventTypeEnum00; entity.Property(p => p.EventTypeEnum00).IsModified = true; } if ((saveMask & BindingSaveMask.EventTypeEnum01) != 0) { model.EventTypeEnum01 = EventTypeEnum01; entity.Property(p => p.EventTypeEnum01).IsModified = true; } if ((saveMask & BindingSaveMask.EventTypeEnum02) != 0) { model.EventTypeEnum02 = EventTypeEnum02; entity.Property(p => p.EventTypeEnum02).IsModified = true; } saveMask = BindingSaveMask.None; } } }