public void OnPlayerPlaceOrderHandler(Client sender, params object[] arguments)
        {
            /* Argumenty
             * args[0] - List<WarehouseItemInfo> JSON
             */

            AccountEntity player = sender.GetAccountEntity();
            GroupEntity   group  = player.CharacterEntity.OnDutyGroup;

            if (group != null)
            {
                List <WarehouseItemInfo> items =
                    JsonConvert.DeserializeObject <List <WarehouseItemInfo> >(arguments[0].ToString());

                decimal sum = items.Sum(x => x.ItemModelInfo.Cost * x.Count);
                if (group.HasMoney(sum))
                {
                    GroupWarehouseOrderModel shipment = new GroupWarehouseOrderModel
                    {
                        //Getter = group.DbModel,
                        //OrderItemsJson = JsonConvert.SerializeObject(items),
                        //ShipmentLog = $"[{DateTime.Now}] Złożenie zamówienia w magazynie. \n"
                    };

                    RoleplayContext ctx = Singletons.RoleplayContextFactory.Create();
                    using (GroupWarehouseOrdersRepository repository = new GroupWarehouseOrdersRepository(ctx))
                    {
                        repository.Insert(shipment);
                        repository.Save();
                    }
                    group.RemoveMoney(sum);

                    CurrentOrders.Add(new WarehouseOrderInfo
                    {
                        Data = shipment
                    });


                    sender.SendInfo("Zamawianie przesyłki zakończyło się pomyślnie.");
                }
                else
                {
                    sender.SendError($"Grupa {group.GetColoredName()} nie posiada wystarczającej ilości środków.");
                }
            }
        }
Exemplo n.º 2
0
 public UnitOfWork(RoleplayContext context)
 {
     Context                        = context;
     AccountsRepository             = new AccountsRepository(context);
     BuildingsRepository            = new BuildingsRepository(context);
     CharactersRepository           = new CharactersRepository(context);
     CrimeBotsRepository            = new CrimeBotsRepository(context);
     GroupsRepository               = new GroupsRepository(context);
     GroupWarehouseItemsRepository  = new GroupWarehouseItemsRepository(context);
     GroupWarehouseOrdersRepository = new GroupWarehouseOrdersRepository(context);
     ItemsRepository                = new ItemsRepository(context);
     PenaltiesRepository            = new PenaltiesRepository(context);
     TelephoneContactsRepository    = new TelephoneContactsRepository(context);
     TelephoneMessagesRepository    = new TelephoneMessagesRepository(context);
     VehiclesRepository             = new VehiclesRepository(context);
     WorkersRepository              = new WorkersRepository(context);
     ZonesRepository                = new ZonesRepository(context);
     GroupRanksRepository           = new GroupRankRepository(context);
     TicketsRepository              = new TicketsRepository(context);
     ItemTemplatesRepository        = new ItemTemplatesRepository(context);
 }