示例#1
0
 private C13ViewModel DbToC13Model(Econ_D_Var data)
 {
     return(new C13ViewModel()
     {
         Year_Quartly = data.Year_Quartly,
         Consumer_Price_Index = data.Consumer_Price_Index.ToString(),
         Consumer_Price_Index_Pre_Ind = data.Consumer_Price_Index_Pre_Ind,
         Unemployment_Rate = data.Unemployment_Rate.ToString(),
         Unemployment_Rate_Pre_Ind = data.Unemployment_Rate_Pre_Ind
     });
 }
示例#2
0
        public MSGReturnModel saveC13(string actionType, C13ViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                try
                {
                    Econ_D_Var dataEdit = new Econ_D_Var();

                    if (actionType == "Add")
                    {
                        dataEdit.Year_Quartly = dataModel.Year_Quartly;
                    }
                    else if (actionType == "Modify")
                    {
                        dataEdit = db.Econ_D_Var
                                   .Where(x => x.Year_Quartly == dataModel.Year_Quartly)
                                   .FirstOrDefault();
                    }

                    dataEdit.Consumer_Price_Index         = double.Parse(dataModel.Consumer_Price_Index);
                    dataEdit.Consumer_Price_Index_Pre_Ind = dataModel.Consumer_Price_Index_Pre_Ind;
                    dataEdit.Unemployment_Rate            = double.Parse(dataModel.Unemployment_Rate);
                    dataEdit.Unemployment_Rate_Pre_Ind    = dataModel.Unemployment_Rate_Pre_Ind;

                    if (actionType == "Add")
                    {
                        db.Econ_D_Var.Add(dataEdit);
                    }

                    db.SaveChanges();

                    result.RETURN_FLAG = true;
                }
                catch (Exception ex)
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = ex.Message;
                }
            }

            return(result);
        }