public int PostSymbol(Models.SectorSymbol Value)
        {
            try
            {
                var Symbol = from d in db.MstSymbols where d.Symbol == Value.Symbol select d;

                if (Symbol.Any())
                {
                    Data.TrnSectorSymbol NewSectorSymbol = new Data.TrnSectorSymbol();

                    NewSectorSymbol.SectorId = Value.SectorId;
                    NewSectorSymbol.SymbolId = Symbol.First().Id;
                    NewSectorSymbol.Symbol   = Symbol.First().Symbol;

                    db.TrnSectorSymbols.InsertOnSubmit(NewSectorSymbol);
                    db.SubmitChanges();

                    return(NewSectorSymbol.Id);
                }
                else
                {
                    return(0);
                }
            }
            catch
            {
                return(0);
            }
        }
        public Models.SectorSymbol GetSectorSymbol(String Id)
        {
            Id = Id.Replace(",", "");
            int id = Convert.ToInt32(Id);

            var retryCounter = 0;

            Models.SectorSymbol value;

            while (true)
            {
                try
                {
                    var SectorSymbol = from d in db.TrnSectorSymbols
                                       where d.Id == id
                                       select new Models.SectorSymbol
                    {
                        Id          = d.Id,
                        SectorId    = d.SectorId,
                        Symbol      = d.Symbol,
                        SymbolId    = d.SymbolId,
                        Description = d.MstSymbol.Description
                    };
                    if (SectorSymbol.Count() > 0)
                    {
                        value = SectorSymbol.First();
                    }
                    else
                    {
                        value = new Models.SectorSymbol();
                    }
                    break;
                }
                catch
                {
                    if (retryCounter == 3)
                    {
                        value = new Models.SectorSymbol();
                        break;
                    }

                    System.Threading.Thread.Sleep(1000);
                    retryCounter++;
                }
            }
            return(value);
        }
        public int PutSymbol(String Id, Models.SectorSymbol Value)
        {
            Id = Id.Replace(",", "");
            int id = Convert.ToInt32(Id);

            try
            {
                var SectorSymbols = from d in db.TrnSectorSymbols where d.Id == id select d;

                if (SectorSymbols.Any())
                {
                    var Symbol = from d in db.MstSymbols where d.Symbol == Value.Symbol select d;

                    if (Symbol.Any())
                    {
                        var UpdatedSectorSymbol = SectorSymbols.FirstOrDefault();

                        UpdatedSectorSymbol.SymbolId = Symbol.First().Id;
                        UpdatedSectorSymbol.Symbol   = Symbol.First().Symbol;

                        db.SubmitChanges();

                        return(UpdatedSectorSymbol.Id);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    return(0);
                }
            }
            catch (NullReferenceException)
            {
                return(0);
            }
        }