private A94ViewModel DbToA94Model(Gov_Info_Ticker data) { return(new A94ViewModel() { Country = data.Country, IGS_Index_Map = data.IGS_Index_Map, Short_term_Debt_Map = data.Short_term_Debt_Map, Foreign_Exchange_Map = data.Foreign_Exchange_Map, GDP_Yearly_Map = data.GDP_Yearly_Map }); }
public MSGReturnModel saveA94(string actionType, A94ViewModel dataModel) { MSGReturnModel result = new MSGReturnModel(); using (IFRS9DBEntities db = new IFRS9DBEntities()) { try { Gov_Info_Ticker editData = new Gov_Info_Ticker(); if (actionType == "Add") { if (db.Gov_Info_Ticker.AsNoTracking() .Where(x => x.Country == dataModel.Country) .FirstOrDefault() != null) { result.RETURN_FLAG = false; result.DESCRIPTION = "資料重複:您輸入的 國家 已存在"; return(result); } editData.Country = dataModel.Country; } else if (actionType == "Modify") { editData = db.Gov_Info_Ticker .Where(x => x.Country == dataModel.Country) .FirstOrDefault(); } editData.IGS_Index_Map = dataModel.IGS_Index_Map; editData.Short_term_Debt_Map = dataModel.Short_term_Debt_Map; editData.Foreign_Exchange_Map = dataModel.Foreign_Exchange_Map; editData.GDP_Yearly_Map = dataModel.GDP_Yearly_Map; if (actionType == "Add") { db.Gov_Info_Ticker.Add(editData); } db.SaveChanges(); //Save result.RETURN_FLAG = true; } catch (Exception ex) { result.RETURN_FLAG = false; result.DESCRIPTION = ex.Message; } } return(result); }