Beispiel #1
0
        public bool AddOrUpdateTickerAlias(TickerAlias newTickerAlias)
        {
            try
            {
                if (newTickerAlias == null)
                {
                    Logger.Error("newTickerAlias не может быть null");
                    return(false);
                }

                var dbTikerAlias =
                    context.TickerAlias.FirstOrDefault(
                        x => x.Ticker == newTickerAlias.Ticker && x.Server == newTickerAlias.Server);

                if (dbTikerAlias != null)
                {
                    dbTikerAlias.Ticker = newTickerAlias.Ticker;
                    dbTikerAlias.Server = newTickerAlias.Server;
                    dbTikerAlias.Alias  = newTickerAlias.Alias;
                }
                else
                {
                    context.TickerAlias.Add(newTickerAlias);
                }

                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Logger.Error("AddOrUpdateTickerAllias", ex);
                return(false);
            }

            return(true);
        }
        public ActionResult AddTickerAlias(string brokerCodeArg, string tickerNameArg)
        {
            if (string.IsNullOrWhiteSpace(brokerCodeArg))
            {
                Logger.Error(string.Format("DeleteTickerAlias - невалидный параметр brokerCodeArg: '{0}'", brokerCodeArg));
                return(RedirectToAction("TickerAliasEdit", new { brokerCode = brokerCodeArg }));
            }

            ViewBag.ServerCodeList = serverInstanceRepository.GetServerCodes();
            ViewBag.TickerNameList = tickerRepository.GetTickerNames();

            var model = new TickerAlias {
                Server = brokerCodeArg
            };

            if (!string.IsNullOrEmpty(tickerNameArg))
            {
                var tick = tickerRepository.GetTickerAlias(brokerCodeArg, tickerNameArg);

                model.Ticker = tickerNameArg;
                model.Alias  = tick == null?string.Format("{0}_{1}_alias", brokerCodeArg, tickerNameArg) : tick.Alias;
            }

            return(View(model));
        }
 public ActionResult AddTickerAlias(TickerAlias model)
 {
     tickerRepository.AddOrUpdateTickerAlias(model);
     return(RedirectToAction("TickerAliasEdit", new { brokerCode = model.Server }));
 }