Example #1
0
        public ActionResult chartpieXX()
        {
            var db             = new F1005.Models.MyInvestEntities();
            var cashCount      = db.UsersData.Select(c => c.CashValue).Sum().ToString();
            var stockCount     = db.UsersData.Select(c => c.StockValue).Sum().ToString();
            var FXCount        = db.UsersData.Select(c => c.FXValue).Sum().ToString();
            var InsuranceCount = db.UsersData.Select(c => c.InsuranceValue).Sum().ToString();
            var FundCount      = db.UsersData.Select(c => c.FundValue).Sum().ToString();
            //var total = cashCount + stockCount + FXCount + InsuranceCount + FundCount;

            //var stockCount = db.StockHistory.Select(c => c.stockNetincome * -1).Sum().ToString(); ;
            //var FXCount = db.FXtradeTable.Where(c=>c.TradeClass == "買入").Select(c=>c.NTD).Sum().ToString();
            //var InsuranceCount = db.Insurances.Where(c => c.PurchaseOrWithdraw == true).Select(c => c.CashFlow * -1).Sum().ToString();
            //var FundCount = db.Fund.Where(c => c.BuyOrSell == true).Select(c => c.CashFlow).Sum().ToString();

            var query = db.UsersData.Select(c => new OverallViewModel
            {
                cash      = cashCount,
                stock     = stockCount,
                FX        = FXCount,
                Insurance = InsuranceCount,
                fund      = FundCount
            }).First();

            return(Json(query, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public object Getlist()
        {
            var db  = new F1005.Models.MyInvestEntities();
            var ret = from c in db.CurrencyRate
                      select c;
            dynamic retObject = new { data = ret.ToList() };

            return(retObject);
            //return Ok(retObject); 如果用IHttpActionResult 就需return Ok();
        }
Example #3
0
        //會員清單
        public JsonResult GetUsers()
        {
            var db  = new F1005.Models.MyInvestEntities();
            var ret = db.UsersData.ToList().Where(c => c.UserName != "msit119").Select(c => new BSViewModel {
                UserName = c.UserName,
                Email    = c.Email,
            });

            //dynamic retObject = new { data = ret.ToList() };
            return(Json(ret, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            MyInvestEntities db = new MyInvestEntities();
            var Esum            = db.CashExpense.Sum(c => c.ExAmount);
            var Isum            = db.CashIncome.Sum(c => c.InAmount);
            var net             = Isum - Esum;

            if (net < 0)
            {
                yield return(new ValidationResult("收入不足,無法新增支出項目", new string [] { "ExAmount" }));
            }
        }
Example #5
0
        public JsonResult GetCashE()
        {
            var db  = new F1005.Models.MyInvestEntities();
            var ret = db.CashExpense.ToList().Select(c => new BSViewModel
            {
                UserName   = c.UserName,
                ExCashType = c.ExCashType,
                ExAmount   = c.ExAmount,
                ExDate     = c.ExDate.ToShortDateString(),
                ExNote     = c.ExNote
            });

            //dynamic retObject = new { data = ret.ToList() };
            return(Json(ret, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        public JsonResult GetFund()
        {
            var db  = new F1005.Models.MyInvestEntities();
            var ret = db.Fund.ToList().Select(c => new BSViewModel
            {
                UserName = c.SummaryTable.UserName,
                FundName = c.FundName,
                Date     = c.Date.ToShortDateString(),
                NAV      = c.NAV,
                Units    = c.Units
            });

            //dynamic retObject = new { data = ret.ToList() };
            return(Json(ret, JsonRequestBehavior.AllowGet));
        }
Example #7
0
        public JsonResult GetFX()
        {
            var db  = new F1005.Models.MyInvestEntities();
            var ret = db.FXtradeTable.ToList().Select(c => new BSViewModel
            {
                UserName      = c.SummaryTable.UserName,
                CurrencyClass = c.CurrencyClass,
                TradeDate     = c.SummaryTable.TradeDate.ToShortDateString(),
                TradeClass    = c.TradeClass,
                note          = c.note
            });

            //dynamic retObject = new { data = ret.ToList() };
            return(Json(ret, JsonRequestBehavior.AllowGet));
        }
Example #8
0
        public JsonResult GetStock()
        {
            var db  = new F1005.Models.MyInvestEntities();
            var ret = from c in db.StockHistory
                      select new BSViewModel
            {
                UserName       = c.SummaryTable.UserName,
                stockID        = c.stockID,
                stockPrice     = c.stockPrice,
                stockAmount    = c.stockAmount,
                stockNote      = c.stockNote,
                stockNetincome = c.stockNetincome
            };
            dynamic retObject = new { data = ret.ToList() };

            return(Json(retObject, JsonRequestBehavior.AllowGet));
        }
Example #9
0
        public JsonResult GetIs()
        {
            var db  = new F1005.Models.MyInvestEntities();
            var ret = db.Insurances.ToList().Select(c => new BSViewModel
            {
                UserName       = c.SummaryTable.UserName,
                InsuranceName  = c.InsuranceName,
                PurchaseDate   = c.PurchaseDate.ToShortDateString(),
                WithdrawDate   = c.WithdrawDate.ToShortDateString(),
                PaymentPerYear = c.PaymentPerYear,
                PayYear        = c.PayYear,
                Withdrawal     = c.Withdrawal
            });

            //dynamic retObject = new { data = ret.ToList() };
            return(Json(ret, JsonRequestBehavior.AllowGet));
        }
Example #10
0
        //讀取現在匯率("History","FX")
        public JsonResult Getlist()
        {
            var db = new F1005.Models.MyInvestEntities();
            //var ret = from c in db.CurrencyRate
            //          select c;
            var ret = db.CurrencyRate.ToList().Select(c => new GetCurrencyViewModel
            {
                ID                = c.ID,
                CurrencyClass     = c.CurrencyClass,
                CurrencyClassName = c.Name,
                OnlineBuy         = c.OnlineBuy,
                OnlineSell        = c.OnlineSell,
                Date              = c.Date.Value.ToShortDateString(),
            });

            //dynamic retObject = new { data = ret.ToList() };
            return(Json(ret, JsonRequestBehavior.AllowGet));
        }
Example #11
0
        //後台NAV繪圖
        public ActionResult chartpieX()
        {
            var db             = new F1005.Models.MyInvestEntities();
            var stockCount     = db.StockHistory.Count().ToString();
            var FXCount        = db.FXtradeTable.Count().ToString();
            var InsuranceCount = db.Insurances.Count().ToString();
            var FundCount      = db.Fund.Count().ToString();

            var query = db.StockHistory.Select(c => new OverallViewModel
            {
                X    = stockCount,
                XX   = FXCount,
                XXX  = InsuranceCount,
                XXXX = FundCount
            }).First();

            return(Json(query, JsonRequestBehavior.AllowGet));
        }
Example #12
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (Units < 0)
            {
                yield return(new ValidationResult("贖回單位數大於已持有單位數", new string[] { "Units" }));
            }
            if (Fee < 0 || Fee > 3)
            {
                yield return(new ValidationResult("手續費應該介於0%至3%間", new string[] { "Fee" }));
            }
            MyInvestEntities db = new MyInvestEntities();
            var query           = db.fund_data.Where(D => D.Currancy == "TWD").Select(D => D.FundName).ToList();

            if (!query.Contains(FundName))
            {
                yield return(new ValidationResult("查詢不到您指定的基金", new string[] { "FundName" }));
            }
        }