public bool SaveStockSymbol(StockSymbol symbol) { try { if (symbol == null) { throw new ArgumentNullException("Symbol cannot be null"); } if (string.IsNullOrWhiteSpace(symbol.Ticker) || symbol.Ticker.Length > 10) { throw new ArgumentException("Ticker should be 1 to 10 character long"); } Guid currentUserID = Guid.Parse(HttpContext.Current.User.Identity.GetUserId()); symbol.UserID = currentUserID; _unitOfWork.StockSymbolRepository.Insert(symbol); _unitOfWork.Save(); return(true); } catch (Exception ex) { _log.Create().WriteLog(LogType.HandledLog, this.GetType().Name, "SaveStockSymbol", ex, "Failed to add stock symbol"); } return(false); }
public ActionResult AddStockSymbol(StockSymbol symbol) { if (ModelState.IsValid && _stockSymbolService.SaveStockSymbol(symbol)) return RedirectToAction("StockSymbols"); return View(symbol); }
public ActionResult DeleteStockSymbol(List<Guid> ids) { if (ModelState.IsValid && _stockSymbolService.DeleteStockSymbol(ids)) return RedirectToAction("StockSymbols"); StockSymbol symbol = new StockSymbol(); return View(symbol); }
public bool SaveStockSymbol(StockSymbol symbol) { try { if (symbol == null) throw new ArgumentNullException("Symbol cannot be null"); if (string.IsNullOrWhiteSpace(symbol.Ticker) || symbol.Ticker.Length > 10) throw new ArgumentException("Ticker should be 1 to 10 character long"); Guid currentUserID = Guid.Parse(HttpContext.Current.User.Identity.GetUserId()); symbol.UserID = currentUserID; _unitOfWork.StockSymbolRepository.Insert(symbol); _unitOfWork.Save(); return true; } catch(Exception ex) { _log.Create().WriteLog(LogType.HandledLog, this.GetType().Name, "SaveStockSymbol", ex, "Failed to add stock symbol"); } return false; }
public ActionResult AddStockSymbol() { StockSymbol symbol = new StockSymbol(); return View(symbol); }