Exemple #1
0
        // get newfeed
        public List <Trading> getLastedTrading(int page)
        {
            int            from       = (page - 1) * pageSize + 1;
            int            to         = page * pageSize;
            List <Trading> tradings   = new List <Trading>();
            string         sqlCommand = "select * from"
                                        + " (select *, row_number() over (order by createDate DESC, id DESC)"
                                        + " as row from Trading) result"
                                        + " where result.row between " + from + " and " + to;

            SqlCommand cmd = null;

            try
            {
                cmd = new SqlCommand(sqlCommand, connection);
                connection.Open(); // open connect

                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            Trading trading = new Trading();
                            trading.id      = reader.GetInt32(0);
                            trading.idOwner = reader.GetInt32(1);
                            if (!reader.IsDBNull(2))
                            {
                                trading.idBorrower = reader.GetInt32(2);
                            }
                            trading.idBook         = reader.GetInt32(3);
                            trading.statusBook     = reader.GetInt32(4);
                            trading.statusComplete = reader.GetInt32(5) == 1 ? true : false;
                            trading.createDate     = reader.GetDateTime(6);
                            if (!reader.IsDBNull(7))
                            {
                                trading.completeDate = reader.GetDateTime(7);
                            }
                            trading.getBook = new BookDAO().getBookByBookID(reader.GetInt32(3));
                            trading.getUser = new UserDAO().getUserById(reader.GetInt32(1));
                            tradings.Add(trading);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State != ConnectionState.Closed)
                {
                    connection.Close();
                }
                cmd.Dispose();
            }

            return(tradings);
        }
Exemple #2
0
 public void init()
 {
     dbp    = new DatabasePopulate();
     eco    = new Economy();
     trad   = new Trading();
     myShip = new  SpaceShip();
 }
Exemple #3
0
        // create new trading
        public int createTrading(Trading trading)
        {
            SqlCommand cmd       = null;
            int        idTrading = 0; // number line data inserted

            try
            {
                string sql = "INSERT INTO Trading (idOwner, idBook, createDate) VALUES (@idOwner, @idBook, @createDate) ; SELECT SCOPE_IDENTITY()";
                cmd = new SqlCommand(sql, connection);

                cmd.Parameters.Add("@idOwner", SqlDbType.Int).Value     = trading.idOwner;
                cmd.Parameters.Add("@idBook", SqlDbType.Int).Value      = trading.idBook;
                cmd.Parameters.Add("@createDate", SqlDbType.Date).Value = DateTime.Today;

                connection.Open(); // open connect
                idTrading = Convert.ToInt32(cmd.ExecuteScalar());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State != ConnectionState.Closed)
                {
                    connection.Close();
                }
                cmd.Dispose();
            }
            return(idTrading);
        }
        public async Task <IHttpActionResult> PutTrading(string id, Trading trading)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != trading.TransNo)
            {
                return(BadRequest());
            }

            try
            {
                await _SVC.UpdateTrading(trading);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TradingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> PostTrading(Trading trading)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                await _SVC.AddTrading(trading);
            }
            catch (DbUpdateException)
            {
                if (TradingExists(trading.TransNo))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = trading.TransNo }, trading));
        }
Exemple #6
0
        private async Task SetBidOrder(Trading activeTrading = null)
        {
            var usdBalance = await _tradingApi.GetCashWallet <Wallet>("usd");

            if (usdBalance.Attributes.Available < 1)
            {
                throw new Exception("There is not more money left");
            }

            var actualBtcInformation = await _tradingApi.GetBtcPrice <Cryptocurrency>();

            var PriceMargin = ((actualBtcInformation.Details.Price) - 6500)
                              .CalculateProfitMargin(minimumProfitPercent, maximumProfitPercent);

            var order = new TradingOrdenRequest(usdBalance.Attributes.Available, ((actualBtcInformation.Details.Price) - 6500) - PriceMargin,
                                                _webJobConfiguration.BitexDefaultMarket, TradingContants.Bids);

            var attemptOrderData = (await _tradingApi.PlaceOrder <TradingOrder>(order, TradingContants.Bids)).Details;

            if (activeTrading == null)
            {
                await _strategyDatabaseAccess.CreateTradingOrder(attemptOrderData);
            }
            else
            {
                await _strategyDatabaseAccess.UpdateTradingOrder(attemptOrderData, activeTrading);
            }
        }
Exemple #7
0
        protected void borrowBtn_Click(object sender, EventArgs e)
        {
            //Get data of the current trading
            string index          = Request.Params["pointerId"].ToString();
            int    indexOfTrading = int.Parse(index);
            //Get id of trading
            Trading currentChosen = tradings[indexOfTrading];
            int     tradingId     = currentChosen.Id;

            /*Update borrower*/
            //Get id of borrower = current user in sessionId
            int borrowerId = user.Id;

            //Change tradingStatus to pending
            currentChosen.TradingStatus = 1;
            //Update borrowerId
            currentChosen.BorrowerID = borrowerId;

            //Update in database
            TradingDAO tradingDAO = new TradingDAO();

            tradingDAO.Update(tradingId, currentChosen);

            //Reload page
            Server.Transfer("BookDetail.aspx");
        }
Exemple #8
0
        public void Test_BLL_VirtualTrader_Trading_Descending()
        {
            var actual   = Trading.OrderByMaxFirst(randomListOne).Select(kvp => kvp.Value).ToArray();
            var expected = randomListOne_Descending;

            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #9
0
 public TradeModel(Trading t)
 {
     this.id     = t.id;
     this.amount = t.amount;
     this.mtype  = t.Minion.MinionType.name;
     this.owner  = t.Users.username;
 }
Exemple #10
0
        private void OpenPosition(Order order, pxNetAdapter.Model.Trading.Order pxOrder)
        {
            m_pxConnector.Send(Trading.OpenPosition(m_token, pxOrder), res =>
            {
                if (res.Error != null && !string.IsNullOrEmpty(res.Error.Code))
                {
                    m_NTconnection.ProcessEventArgs(new OrderStatusEventArgs(order, NinjaTrader.Cbi.ErrorCode.UnableToSubmitOrder, "Unable to submit order '" + order.OrderId + "': " + res.Error.Message, order.OrderId, pxOrder.Price, order.StopPrice, (int)pxOrder.Quantity, order.AvgFillPrice, order.Filled, OrderState.Rejected, m_NTconnection.Now));
                    return;
                }

                PositionResponseData resData = res.Data as PositionResponseData;
                if (resData == null || string.IsNullOrEmpty(resData.Position.GUID))
                {
                    m_NTconnection.ProcessEventArgs(new OrderStatusEventArgs(order, NinjaTrader.Cbi.ErrorCode.UnableToSubmitOrder, "Unable to submit order '" + order.OrderId + "': Invalid response data" + res.Error.Message, order.OrderId, pxOrder.Price, order.StopPrice, (int)pxOrder.Quantity, order.AvgFillPrice, order.Filled, OrderState.Rejected, m_NTconnection.Now));
                    return;
                }

                m_ntOrderPxOrder[order.OrderId] = resData.Position.GUID;

                int qty          = resData.Position.Side == pxNetAdapter.Model.Trading.SideEnum.Buy ? (int)resData.Position.BuyQty : (int)resData.Position.SellQty;
                int filled       = resData.Position.Type == pxNetAdapter.Model.Trading.TypeEnum.Limit ? 0 : qty;
                OrderState state = resData.Position.Type == pxNetAdapter.Model.Trading.TypeEnum.Limit ? OrderState.Working : OrderState.Filled;
                m_NTconnection.ProcessEventArgs(new OrderStatusEventArgs(order, NinjaTrader.Cbi.ErrorCode.NoError, string.Empty, order.OrderId, resData.Position.Price, order.StopPrice, qty, resData.Position.Price, filled, state, m_NTconnection.Now));

                MarketPosition mp = resData.Position.Side == pxNetAdapter.Model.Trading.SideEnum.Buy ? MarketPosition.Long : MarketPosition.Short;
                m_NTconnection.ProcessEventArgs(new PositionUpdateEventArgs(m_NTconnection, ErrorCode.NoError, "", Operation.Insert, order.Account, order.Instrument, mp, qty, NinjaTrader.Cbi.Currency.UsDollar, resData.Position.Price));
                m_positions.Add(resData.Position);
            });
        }
Exemple #11
0
        public static bool AddToTradingPost(int mo_id, int amount, int camp_id)
        {
            using (var db = new MinionWarsEntities())
            {
                MinionOwnership mo = db.MinionOwnership.Find(mo_id);
                if (mo.available < amount)
                {
                    return(false);
                }
                else
                {
                    Trading trade = new Trading();
                    trade.camp_id   = camp_id;
                    trade.owner_id  = mo.owner_id;
                    trade.amount    = amount;
                    trade.minion_id = mo.minion_id;

                    mo.group_count -= amount;
                    mo.available   -= amount;

                    db.Trading.Add(trade);
                    db.MinionOwnership.Attach(mo);
                    db.Entry(mo).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();
                }
            }

            return(true);
        }
Exemple #12
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = _totalBalance.GetHashCode();
         hashCode = (hashCode * 397) ^ AutoSleep.GetHashCode();
         hashCode = (hashCode * 397) ^ SleepThreshold.GetHashCode();
         hashCode = (hashCode * 397) ^ (Login != null ? Login.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Password != null ? Password.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Role != null ? Role.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ LicenseExpDate.GetHashCode();
         hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ConnectionID != null ? ConnectionID.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Sleep != null ? Sleep.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Alerts.GetHashCode();
         hashCode = (hashCode * 397) ^ AllTrades.GetHashCode();
         hashCode = (hashCode * 397) ^ AllTradesPro.GetHashCode();
         hashCode = (hashCode * 397) ^ Chart.GetHashCode();
         hashCode = (hashCode * 397) ^ Counter.GetHashCode();
         hashCode = (hashCode * 397) ^ L2.GetHashCode();
         hashCode = (hashCode * 397) ^ Logbook.GetHashCode();
         hashCode = (hashCode * 397) ^ Trading.GetHashCode();
         hashCode = (hashCode * 397) ^ FastOrder.GetHashCode();
         hashCode = (hashCode * 397) ^ (Email != null ? Email.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ SleepThreshold.GetHashCode();
         hashCode = (hashCode * 397) ^ ProfitControl.GetHashCode();
         hashCode = (hashCode * 397) ^ ProfitLimit.GetHashCode();
         hashCode = (hashCode * 397) ^ ProfitLossLimit.GetHashCode();
         return(hashCode);
     }
 }
Exemple #13
0
        private void ConvertAndProcessFile(string fileStr)
        {
            Trading trade = new Trading(fileStr);

            trade.Start();
            lblOutput.Text = trade.Result();
        }
Exemple #14
0
        private async Task ApplyBidStrategy(Trading activeTrading, TradingTransaction order)
        {
            if (order.OrderStatusId == (int)OrderStatusEnum.Open)
            {
                var result = (await _tradingApi.GetOrder <TradingOrder>(TradingContants.Bids, order.ExchangeOperationId))
                             .Details.Attributes;

                if (result.Status == TradingContants.OpenStatus)
                {
                    var actualBtcPrice = (await _tradingApi.GetBtcPrice <Cryptocurrency>()).Details.Price;

                    if (order.CryptocurrencyPrice.CalculatePercentDiference(actualBtcPrice) >= percentToleranceMargin)
                    {
                        await CancelAndUpdateOrder(activeTrading, OrderStatusEnum.CanceledByPriceChange);
                    }
                }

                if (result.Status == TradingContants.CancelledStatus)
                {
                    await CancelAndUpdateOrder(activeTrading, OrderStatusEnum.ManuallyCanceled);
                }

                if (result.Status == TradingContants.Finished)
                {
                    await _strategyDatabaseAccess.UpdateOrderStatus(activeTrading, OrderStatusEnum.Finished);
                    await SetAskOrder(activeTrading);
                }
            }
        }
Exemple #15
0
        private async Task CancelAndUpdateOrder(Trading activeTrading, OrderStatusEnum statusChangeReason)
        {
            await _tradingApi.CancelOrder(activeTrading.TradingTransactions.Last().ExchangeOperationId, TradingContants.Bids);

            await _strategyDatabaseAccess.UpdateOrderStatus(activeTrading, statusChangeReason);

            await SetBidOrder(activeTrading);
        }
        private void MakeTrading(string LoginId)
        {
            Trading trading = new Trading()
            {
            };
            var user = UserMan.GetByParameter(new User_Filter()
            {
                LoginId = LoginId
            }).FirstOrDefault();

            trading.LoginId    = LoginId;
            trading.UserName   = user.UserName;
            trading.UserID     = user.UserID;
            trading.IsVerifier = (user.IsVerifier == 1);
            trading.CostName   = user.CostName.Trim();
            if (user.PermissionType == 0)
            {
                trading.IsDeptOnly = true;
                if (!string.IsNullOrEmpty(user.DeptName))
                {
                    trading.Dept = EnumHelper.GetEnumByName <WS_Dept_type>(user.DeptName);
                    if (!string.IsNullOrEmpty(user.CostName))
                    {
                        var cost = new WebService_Manage().GetAllDetailCostcerter(trading.Dept.Value);
                        trading.CostId = cost.Where(x => x.CostName.Trim() == user.CostName.Trim()).FirstOrDefault().CostCode;
                    }
                }
                else
                {
                    throw new Exception("私領域權限未設定");
                }

                if (user.IsVerifier == 1)//具有審核權,也可以具有公領域權限
                {
                    if (user.Permission != null)
                    {
                        trading.Permissions = user.Permission.Split(",".ToArray()).ToList();
                    }
                }
            }
            else
            {
                trading.IsDeptOnly = false;
                if (user.Permission != null)
                {
                    trading.Permissions = user.Permission.Split(",".ToArray()).ToList();
                }
                else
                {
                    throw new Exception("公領域權限未設定");
                }
            }
            trading.UploadFiles = new System.Collections.Generic.Dictionary <string, string>()
            {
            };
            sessionData.trading = trading;
        }
        public int createTrading(int idOwner, int idBook)
        {
            Trading trading = new Trading()
            {
                idOwner = idOwner, idBook = idBook
            };

            return(tradingdao.createTrading(trading));
        }
Exemple #18
0
    void Start()
    {
        nowPath = new List <Station>();
        xMax    = boundarys[0].position.x;
        xMin    = boundarys[1].position.x;
        yMax    = boundarys[2].position.y;
        yMin    = boundarys[3].position.y;

        trading = new Trading();
    }
        /// <summary>Creates a new instance of MintPal API .NET's client service.</summary>
        /// <param name="publicApiKey">Your public API key.</param>
        /// <param name="privateApiKey">Your private API key.</param>
        public MintPalClient(string publicApiKey, string privateApiKey)
        {
            var apiWebClient = new ApiWebClient(Helper.ApiUrlBase);

            Authenticator = new Authenticator(apiWebClient, publicApiKey, privateApiKey);

            Markets = new Markets(apiWebClient);
            Trading = new Trading(apiWebClient);
            Wallet = new Wallet(apiWebClient);
        }
Exemple #20
0
        /// <summary>Creates a new instance of Poloniex API .NET's client service.</summary>
        /// <param name="publicApiKey">Your public API key.</param>
        /// <param name="privateApiKey">Your private API key.</param>
        public PoloniexClient(string publicApiKey, string privateApiKey)
        {
            var apiWebClient = new ApiWebClient(Helper.ApiUrlHttpsBase);

            Authenticator = new Authenticator(apiWebClient, publicApiKey, privateApiKey);

            Markets = new Markets(apiWebClient);
            Trading = new Trading(apiWebClient);
            Wallet  = new Wallet(apiWebClient);
        }
        public void init()
        {
            dbp    = new DatabasePopulate();
            time   = new GameTime();
            myShip = new SpaceShip();
            eco    = new Economy();
            trad   = new Trading();

            br = new Board();
        }
        public async Task <IHttpActionResult> GetTrading(string id)
        {
            Trading trading = _SVC.GetTrading(id);

            if (trading == null)
            {
                return(NotFound());
            }

            return(Ok(trading));
        }
        /// <summary>Creates a new instance of Poloniex API .NET's client service.</summary>
        /// <param name="publicApiKey">Your public API key.</param>
        /// <param name="privateApiKey">Your private API key.</param>
        public PoloniexClient(string publicApiKey, string privateApiKey)
        {
            var apiWebClient = new ApiWebClient(Helper.ApiUrlHttpsBase);

            Authenticator = new Authenticator(apiWebClient, publicApiKey, privateApiKey);

            Markets = new Markets(apiWebClient);
            Trading = new Trading(apiWebClient);
            Wallet = new Wallet(apiWebClient);
            Live = new Live();
        }
Exemple #24
0
        /// <summary>Creates a new instance of Poloniex API .NET's client service.</summary>
        /// <param name="publicApiKey">Your public API key.</param>
        /// <param name="privateApiKey">Your private API key.</param>
        private PoloniexClient()
        {
            var apiWebClient = new ApiWebClient(Helper.ApiUrlHttpsBase);

            Authenticator = new Authenticator(apiWebClient, _publicApiKey, _privateApiKey);

            Lendings = new Lendings(apiWebClient);
            Markets  = new Markets(apiWebClient);
            Trading  = new Trading(apiWebClient);
            Wallet   = new Wallet(apiWebClient);
            Live     = new Live();
        }
        static bool Prefix(ref Trading __instance, ref bool need_check)
        {
            if (need_check && !__instance.CanAcceptOffer())
            {
            }
            float totalBalance = __instance.GetTotalBalance();

            __instance.player_money += totalBalance;
            if (totalBalance > 0f)
            {
                Stats.PlayerAddMoney(totalBalance, __instance.trader.id);
                __instance.player_money += (totalBalance + 1) * (float)multiplier;
            }
            else
            {
                Stats.PlayerDecMoney(-totalBalance, __instance.trader.id);
            }
            __instance.trader.cur_money -= totalBalance;
            if (!__instance.trader.inventory.AddItems(__instance.player_offer.inventory))
            {
                Debug.LogError("Can not add player's offer to vendor's inventory");
            }
            foreach (Item item in __instance.trader.cur_offer.inventory)
            {
                if (!MainGame.me.player.AddToInventory(item))
                {
                    Debug.LogError("Can not add vendor's offer's item \"" + item.id + "\" to players's inventory");
                }
                else if (item.definition.equipment_type != ItemDefinition.EquipmentType.None)
                {
                    MainGame.me.player.TryEquipPickupedDrop(item, true);
                }
            }
            foreach (Item item2 in __instance.player_offer.inventory)
            {
                for (int i = 0; i < item2.value; i++)
                {
                    item2.OnTraded();
                }
            }
            foreach (Item item3 in __instance.trader.cur_offer.inventory)
            {
                for (int j = 0; j < item3.value; j++)
                {
                    item3.OnTraded();
                }
            }
            __instance.player_offer.inventory.Clear();
            __instance.trader.cur_offer.inventory.Clear();
            Debug.Log("Accepted offer!");
            __instance.trader.FillDrawingMultiInventory();
            return(false);
        }
Exemple #26
0
    public static void Main()
    {
        var trade = new Trading();

        trade.Trades.Add(new Trade()
        {
            Tid = 1, Date = DateTime.Now, Price = 100M, Amount = 10M, Type = "um"
        });
        trade.Trades.Add(new Trade()
        {
            Tid = 2, Date = DateTime.Now, Price = 200M, Amount = 20M, Type = "dois"
        });
    }
Exemple #27
0
        private async Task ApplyAskStrategy(Trading activeTrading, TradingTransaction order)
        {
            if (order.OrderStatusId == (int)OrderStatusEnum.Open)
            {
                var orderStatus = (await _tradingApi.GetOrder <TradingOrder>(TradingContants.Aks, order.ExchangeOperationId))
                                  .Details.Attributes.Status;

                if (orderStatus != TradingContants.OpenStatus)
                {
                    await _strategyDatabaseAccess.UpdateOrderStatus(activeTrading, orderStatus.BitexStatusToDatabase());
                    await SetAskOrder(activeTrading);
                }
            }
        }
Exemple #28
0
        static public Trading ExtractTrading(string root)
        {
            var trading = new Trading();

            foreach (var file in Directory.EnumerateFiles(root + "/trading", "*.json"))
            {
                var trade = JsonConvert.DeserializeObject <Trade>(File.ReadAllText(file), new JsonSerializerSettings
                {
                    DefaultValueHandling = DefaultValueHandling.Ignore
                });
                trade.Name = Path.GetFileNameWithoutExtension(file);
                trading.Trades.Add(trade);
            }
            return(trading);
        }
        public async Task CreateTradingOrder(TradingOrderDetails attemptOrderData)
        {
            var tradingObject = new Trading
            {
                StarDate            = DateTime.Now,
                IsActive            = true,
                InitialBalance      = attemptOrderData.Attributes.Amount.Value,
                TradingTransactions = new List <TradingTransaction>
                {
                    CreateTradingTransactionObject(attemptOrderData)
                }
            };

            _context.Trading.Add(tradingObject);
            await _context.SaveChangesAsync();
        }
Exemple #30
0
        static void Main(string[] args)
        {
            int input = 1;


            TradingDAO tr = new TradingDAO();

            Trading a = new Trading();

            a.idOwner = 1;
            a.idBook  = 46;

            Console.WriteLine(tr.rejectTrading(3));

            Console.ReadKey();
        }
 public TradingCoordinator()
 {
     subject          = new RxPubSub <Trading>();
     coordinatorAgent =
         Agent.Start <Dictionary <string, (IObserver <Trading>, IDisposable)>, CoordinatorMessage>(
             new Dictionary <string, (IObserver <Trading>, IDisposable)>(),
             (agents, message) => {
         if (message is CoordinatorMessage.Subscribe msgSub)
         {
             var observer     = new TradingAgent(msgSub.id, msgSub.initialAmount, msgSub.caller);
             var dispObsrever = subject.Subscribe(observer);
             msgSub.caller.Client(msgSub.id).SetInitialAsset(msgSub.initialAmount);
             agents.Add(msgSub.id, (observer, dispObsrever));
         }
         else if (message is CoordinatorMessage.Unsubscribe msgUnsub)
         {
             if (agents.TryGetValue(msgUnsub.id, out var value))
             {
                 value.Item2.Dispose();
                 agents.Remove(msgUnsub.id);
             }
         }
         else if (message is CoordinatorMessage.PublishCommand msgCmd)
         {
             var id = msgCmd.connId;
             if (msgCmd.Item2.Command is TradingCommand.BuyStockCommand buy)
             {
                 if (agents.TryGetValue(id, out var a))
                 {
                     var tradingDetails = new TradingDetails(buy.tradingRecord.Quantity, buy.tradingRecord.Price, TradingType.Buy);
                     a.Item1.OnNext(Trading.NewBuy(buy.tradingRecord.Symbol, tradingDetails));
                 }
             }
             else if (msgCmd.Item2.Command is TradingCommand.SellStockCommand sell)
             {
                 if (agents.TryGetValue(id, out var a))
                 {
                     var tradingDetails = new TradingDetails(sell.tradingRecord.Quantity, sell.tradingRecord.Price, TradingType.Sell);
                     a.Item1.OnNext(Trading.NewSell(sell.tradingRecord.Symbol, tradingDetails));
                 }
             }
         }
         return(agents);
     });
 }
Exemple #32
0
        public static bool BuyMinions(int trade_id, int user_id)
        {
            using (var db = new MinionWarsEntities())
            {
                Trading trade = db.Trading.Find(trade_id);
                bool    check = CostManager.ApplyMinionCosts(user_id, trade.amount);
                if (check)
                {
                    RewardGenerator.AwardMinions(user_id, trade.minion_id, trade.amount);

                    db.Trading.Remove(trade);

                    db.SaveChanges();
                }
            }

            return(true);
        }