public bool AddScriptData(List <StockCall> calls)
 {
     using (StockMasterEntities et = new StockMasterEntities())
     {
         foreach (var call in calls)
         {
             et.ScriptDatas.Add(new ScriptData
             {
                 Code    = call.Stock,
                 tDate   = call.Date,
                 tOpen   = call.Open,
                 tHigh   = call.High,
                 tLow    = call.Low,
                 tClose  = call.Close,
                 Volume  = Convert.ToInt64(call.Volume),
                 EMA9    = call.EMA9,
                 EMA21   = call.EMA21,
                 tCall   = call.Call,
                 tStatus = "Initial",
                 tEntry  = 0,
                 tExit   = 0,
                 LotSize = 0
             });
         }
         et.SaveChangesAsync();
     }
     return(true);
 }
        public List <StockCall> GetScriptCalls(string script)
        {
            List <StockCall> calls = new List <StockCall>();

            using (StockMasterEntities et = new StockMasterEntities())
            {
                foreach (var call in et.ScriptDatas.Where(s => s.Code == script && (s.tCall == "BUY" || s.tCall == "SELL")).OrderByDescending(t => t.tDate))
                {
                    calls.Add(new StockCall
                    {
                        Stock   = call.Code,
                        Date    = call.tDate,
                        Open    = call.tOpen,
                        High    = call.tHigh,
                        Low     = call.tLow,
                        Close   = call.tClose,
                        Volume  = Convert.ToDecimal(call.Volume),
                        EMA9    = call.EMA9,
                        EMA21   = call.EMA21,
                        Call    = call.tCall,
                        Status  = call.tStatus,
                        Entry   = call.tEntry,
                        Exit    = call.tExit,
                        LotSize = call.LotSize
                    });
                }
            }
            return(calls);
        }