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();
            }
        }
Пример #2
0
 public void AddWorker(WorkerModel worker)
 {
     using (RoleplayContext ctx = Singletons.RoleplayContextFactory.Create())
     {
         ctx.Attach(DbModel);
         DbModel.Workers.Add(worker);
         ctx.SaveChanges();
     }
 }
        public void PutItemToBuilding(Client player, ItemModel itemModel)
        {
            using (RoleplayContext ctx = Singletons.RoleplayContextFactory.Create())
            {
                ctx.Attach(DbModel);
                ctx.Attach(itemModel);

                DbModel.ItemsInBuilding.Add(itemModel);
                itemModel.Building  = DbModel;
                itemModel.Character = null;

                ctx.SaveChanges();
            }
        }
Пример #4
0
 public void Dispose()
 {
     _context.SaveChanges();
 }