public JsonResult SaveIssuerTicker(string actionType, IssuerTickerViewModel dataModel) { MSGReturnModel result = new MSGReturnModel(); result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.parameter_Error.GetDescription(); try { MSGReturnModel resultSave = TickerRatingRepository.saveIssuerTicker(actionType, dataModel); result.RETURN_FLAG = resultSave.RETURN_FLAG; result.DESCRIPTION = Message_Type.save_Success.GetDescription(); if (!result.RETURN_FLAG) { result.DESCRIPTION = Message_Type.save_Fail.GetDescription() + " " + resultSave.DESCRIPTION; } } catch (Exception ex) { result.RETURN_FLAG = false; result.DESCRIPTION = ex.Message; } return(Json(result)); }
public MSGReturnModel saveIssuerTicker(string actionType, IssuerTickerViewModel dataModel) { MSGReturnModel result = new MSGReturnModel(); using (IFRS9DBEntities db = new IFRS9DBEntities()) { try { if (actionType == "Add") { if (db.Issuer_Ticker.AsNoTracking() .Where(x => x.Issuer == dataModel.Issuer) .Count() > 0) { result.RETURN_FLAG = false; result.DESCRIPTION = string.Format("資料重複:{0} 已存在", dataModel.Issuer); return(result); } Issuer_Ticker addData = new Issuer_Ticker(); addData.Issuer = dataModel.Issuer; addData.ISSUER_EQUITY_TICKER = dataModel.ISSUER_EQUITY_TICKER; addData.Create_User = _UserInfo._user; addData.Create_Time = _UserInfo._time; addData.Create_Date = _UserInfo._date; db.Issuer_Ticker.Add(addData); } else if (actionType == "Modify") { Issuer_Ticker oldData = db.Issuer_Ticker .Where(x => x.Issuer == dataModel.Issuer) .FirstOrDefault(); oldData.ISSUER_EQUITY_TICKER = dataModel.ISSUER_EQUITY_TICKER; oldData.LastUpdate_User = _UserInfo._user; oldData.LastUpdate_Date = _UserInfo._date; oldData.LastUpdate_Time = _UserInfo._time; } db.SaveChanges(); result.RETURN_FLAG = true; } catch (DbUpdateException ex) { result.RETURN_FLAG = false; result.DESCRIPTION = ex.Message; } } return(result); }
public JsonResult GetIssuerTickerData(string queryType, IssuerTickerViewModel dataModel) { MSGReturnModel result = new MSGReturnModel(); result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.not_Find_Any.GetDescription(); try { var queryData = TickerRatingRepository.getIssuerTicker(queryType, dataModel); result.RETURN_FLAG = queryData.Item1; result.Datas = Json(queryData.Item2); } catch (Exception ex) { result.RETURN_FLAG = false; result.DESCRIPTION = ex.Message; } return(Json(result)); }
public Tuple <bool, List <IssuerTickerViewModel> > getIssuerTicker(string queryType, IssuerTickerViewModel dataModel) { using (IFRS9DBEntities db = new IFRS9DBEntities()) { var query = from q in db.Issuer_Ticker.AsNoTracking() select q; if (dataModel.Issuer_Ticker_ID.IsNullOrWhiteSpace() == false) { query = query.Where(x => x.Issuer_Ticker_ID.ToString() == dataModel.Issuer_Ticker_ID); } if (dataModel.Issuer.IsNullOrWhiteSpace() == false) { query = query.Where(x => x.Issuer == dataModel.Issuer); } if (dataModel.ISSUER_EQUITY_TICKER.IsNullOrWhiteSpace() == false) { query = query.Where(x => x.ISSUER_EQUITY_TICKER == dataModel.ISSUER_EQUITY_TICKER); } bool item1 = true; if (queryType != "ALL") { item1 = query.Any(); } return(new Tuple <bool, List <IssuerTickerViewModel> >( item1, query.AsEnumerable() .Select(x => { return DbToIssuerTickerModel(x); }).ToList())); } }