Example #1
0
        public async Task <IActionResult> AddTrades(AddTradeViewModel tradeToAdd)
        {
            var userId = GetUserId();

            if (tradeToAdd.SkipDuplicate)
            {
                var existingTrade = await _dbContext.Trades.SingleOrDefaultAsync(trade => trade.UserId == userId && trade.Raw == tradeToAdd.Raw);

                if (existingTrade != null)
                {
                    return(Ok());
                }
            }

            var trade = new Trade
            {
                Id     = Guid.NewGuid().ToString(),
                Raw    = tradeToAdd.Raw,
                UserId = userId
            };

            this._dbContext.Trades.Add(trade);
            await this._dbContext.SaveChangesAsync();

            return(Ok());
        }
        public ActionResult AddTrade()
        {
            var model = new AddTradeViewModel()
            {
                TradeGroups = blTradeGroup.Select().ToList()
            };

            return(View(model));
        }
Example #3
0
        public IActionResult AddTrade(AddTradeViewModel tradeModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(tradeModel));
            }

            this.tradeService.AddTrade(tradeModel.TradePair, tradeModel.OrderType, tradeModel.TradeStatus, tradeModel.Quantity, tradeModel.ExecutionPrice,
                                       tradeModel.ExecutionDate, tradeModel.ClosingPrice, tradeModel.ClosingDate, tradeModel.StopLoss, tradeModel.TakeProfit, tradeModel.ReasonForEntry,
                                       tradeModel.Swap, tradeModel.Commissions, tradeModel.Notes, tradeModel.Image);

            return(this.RedirectToAction(nameof(AllTrades)));
        }
        public ActionResult EditTrade(long?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Error404", "Home"));
            }

            var model = new AddTradeViewModel()
            {
                TradeGroups = blTradeGroup.Select().ToList(),
                Trade       = blTrade.Find(Convert.ToInt64(id))
            };

            return(View(model));
        }