示例#1
0
        public MSGReturnModel saveGuarantorTicker(string actionType, GuarantorTickerViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                try
                {
                    if (actionType == "Add")
                    {
                        if (db.Guarantor_Ticker.AsNoTracking()
                            .Where(x => x.Issuer == dataModel.Issuer)
                            .Count() > 0)
                        {
                            result.RETURN_FLAG = false;
                            result.DESCRIPTION = string.Format("資料重複:{0} 已存在", dataModel.Issuer);
                            return(result);
                        }

                        Guarantor_Ticker addData = new Guarantor_Ticker();

                        addData.Issuer               = dataModel.Issuer;
                        addData.GUARANTOR_NAME       = dataModel.GUARANTOR_NAME;
                        addData.GUARANTOR_EQY_TICKER = dataModel.GUARANTOR_EQY_TICKER;
                        addData.Create_User          = _UserInfo._user;
                        addData.Create_Date          = _UserInfo._date;
                        addData.Create_Time          = _UserInfo._time;
                        db.Guarantor_Ticker.Add(addData);
                    }
                    else if (actionType == "Modify")
                    {
                        Guarantor_Ticker oldData = db.Guarantor_Ticker
                                                   .Where(x => x.Issuer == dataModel.Issuer)
                                                   .FirstOrDefault();
                        oldData.GUARANTOR_NAME       = dataModel.GUARANTOR_NAME;
                        oldData.GUARANTOR_EQY_TICKER = dataModel.GUARANTOR_EQY_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);
        }
示例#2
0
 private GuarantorTickerViewModel DbToGuarantorTickerModel(Guarantor_Ticker data)
 {
     return(new GuarantorTickerViewModel()
     {
         Table_Name = "Guarantor_Ticker",
         Guarantor_Ticker_ID = data.Guarantor_Ticker_ID.ToString(),
         Issuer = data.Issuer,
         GUARANTOR_NAME = data.GUARANTOR_NAME,
         GUARANTOR_EQY_TICKER = data.GUARANTOR_EQY_TICKER
     });
 }