コード例 #1
0
ファイル: C1Controller.cs プロジェクト: wcsy0827/IFRS9
        public JsonResult SaveC13(string actionType, C13ViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Message_Type.parameter_Error.GetDescription();

            try
            {
                MSGReturnModel resultSave = C1Repository.saveC13(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));
        }
コード例 #2
0
ファイル: C1Controller.cs プロジェクト: wcsy0827/IFRS9
        public JsonResult GetC13Data(C13ViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Message_Type.not_Find_Any.GetDescription();

            try
            {
                var queryResult = C1Repository.getC13(dataModel);

                result.RETURN_FLAG = queryResult.Item1;

                Cache.Invalidate(CacheList.C13DbfileData);             //清除
                Cache.Set(CacheList.C13DbfileData, queryResult.Item2); //把資料存到 Cache

                if (!result.RETURN_FLAG)
                {
                    result.DESCRIPTION = Message_Type.not_Find_Any.GetDescription();
                }
            }
            catch (Exception ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = ex.Message;
            }

            return(Json(result));
        }
コード例 #3
0
ファイル: C1Repository.cs プロジェクト: wcsy0827/IFRS9
        public Tuple <bool, List <C13ViewModel> > getC13(C13ViewModel dataModel)
        {
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                if (db.Econ_D_Var.Any())
                {
                    var query = db.Econ_D_Var.AsNoTracking()
                                .Where(x => x.Year_Quartly.Contains(dataModel.Year_Quartly), dataModel.Year_Quartly.IsNullOrWhiteSpace() == false)
                                .Where(x => x.Consumer_Price_Index_Pre_Ind == dataModel.Consumer_Price_Index_Pre_Ind, dataModel.Consumer_Price_Index_Pre_Ind.IsNullOrWhiteSpace() == false)
                                .Where(x => x.Unemployment_Rate_Pre_Ind == dataModel.Unemployment_Rate_Pre_Ind, dataModel.Unemployment_Rate_Pre_Ind.IsNullOrWhiteSpace() == false);

                    return(new Tuple <bool, List <C13ViewModel> >(query.Any(), query.AsEnumerable()
                                                                  .Select(x => { return DbToC13Model(x); }).ToList()));
                }
            }

            return(new Tuple <bool, List <C13ViewModel> >(false, new List <C13ViewModel>()));
        }
コード例 #4
0
ファイル: C1Repository.cs プロジェクト: wcsy0827/IFRS9
        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);
        }