public async Task <IActionResult> Create([Bind("Id,CompanyName,NumberOfTotalStocks,StocksSold,StockPrice")] Company company) { if (ModelState.IsValid) { _context.Add(company); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(company)); }
public async Task <IActionResult> Create([Bind("Id,BuyerName,EmailAddress")] StocksBuyer stocksBuyer) { if (ModelState.IsValid) { _context.Add(stocksBuyer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(stocksBuyer)); }
public async Task <IActionResult> Create([Bind("Id,CompanyId,StocksBuyerId,NumberOfStocks")] StocksPayment stocksPayment) { if (ModelState.IsValid) { var company = (from companies in _context.Company where companies.Id == stocksPayment.CompanyId select companies).FirstOrDefault(); company.StocksSold = company.StocksSold + stocksPayment.NumberOfStocks; stocksPayment.Id = 0; _context.StocksPayment.Add(stocksPayment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Details), new { id = stocksPayment.Id })); } return(View(stocksPayment)); }