public async Task <IActionResult> Create(Trade trade)
        {
            try
            {
                if (Exists(trade.Code, trade.Id))
                {
                    ModelState.AddModelError("Code", "Já existe uma negociação cadastrada com este código.");
                }

                if (ModelState.IsValid)
                {
                    _context.Add(trade);

                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (DbUpdateException)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }

            return(View(trade));
        }
        public async Task <IActionResult> Create([Bind("ID,Ticker,StockName,Price")] StockModel stockModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(stockModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(stockModel));
        }