public void Buy(Client sender) { if (DbModel.AutoSaleModel == null) { sender.SendWarning("Ten budynek nie jest na sprzedaż"); return; } using (RoleplayContext ctx = Singletons.RoleplayContextFactory.Create()) { ctx.Attach(DbModel); CharacterEntity character = sender.GetAccountEntity().CharacterEntity; if (!character.HasMoney(DbModel.AutoSaleModel.Cost)) { sender.SendError("Nie posiadasz wystarczającej ilości gotówki"); return; } BuildingMarker.Color = new Color(255, 255, 0); character.RemoveMoney(DbModel.AutoSaleModel.Cost); sender.TriggerEvent(Constant.RemoteEvents.RemoteEvents.CharacterShowShardRequested, "Zakupiono budynek", 5000); NAPI.Player.PlaySoundFrontEnd(sender, "BASE_JUMP_PASSED", "HUD_AWARDS"); DbModel.Character = character.DbModel; ctx.Remove(DbModel.AutoSaleModel); DbModel.AutoSaleModel = null; ctx.SaveChanges(); } }
public void Delete <T>(T entity) where T : class { _context.Remove(entity); }