コード例 #1
0
        public void AddAccountBook(AccountBook entity)
        {
            SkillTreeHomeworkEntities1 _dbcontext = new SkillTreeHomeworkEntities1();

            _dbcontext.AccountBook.Add(entity);
            _dbcontext.SaveChanges();
        }
コード例 #2
0
ファイル: EditController.cs プロジェクト: yachun0728/Homework
        public List <MoneyListDisplayModel> DisplayList(DateTime date)
        {
            var skillTreeHomeworkEntities = new SkillTreeHomeworkEntities1();

            return(skillTreeHomeworkEntities.AccountBooks
                   .Where(a => a.Dateee == date)
                   .Select(a => new MoneyListDisplayModel()
            {
                Id = a.Id.ToString(),
                CategoryDisplay = a.Categoryyy,
                Money = a.Amounttt,
                Date = a.Dateee
            }).ToList());
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: yachun0728/Homework
 public ActionResult Index([Bind(Include = "Category, Money, Date, Description")] MoneyList moneyList)
 {
     if (ModelState.IsValid)
     {
         var skillTreeHomeworkEntities = new SkillTreeHomeworkEntities1();
         skillTreeHomeworkEntities.AccountBooks.Add(new AccountBook()
         {
             Id         = Guid.NewGuid(),
             Categoryyy = int.Parse(moneyList.Category),
             Amounttt   = (int)moneyList.Money,
             Dateee     = moneyList.Date,
             Remarkkk   = moneyList.Description
         });
         skillTreeHomeworkEntities.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: yachun0728/Homework
        public ActionResult List()
        {
            var skillTreeHomeworkEntities = new SkillTreeHomeworkEntities1();
            int number = 1;

            var moneyList = skillTreeHomeworkEntities.AccountBooks.OrderByDescending(a => a.Dateee).Take(10).Select(a => new MoneyListDisplayModel()
            {
                Id = a.Id.ToString(),
                CategoryDisplay = a.Categoryyy,
                Money           = a.Amounttt,
                Date            = a.Dateee
            }).ToList();

            foreach (var mm in moneyList)
            {
                mm.Category = _EnumHelper.GetEnumDisplayName((Category)mm.CategoryDisplay);
                mm.Number   = number;
                ++number;
            }
            //888
            return(View(moneyList));
        }
コード例 #5
0
        public List <AccountBook> GetAccountBooks()
        {
            SkillTreeHomeworkEntities1 _dbcontext = new SkillTreeHomeworkEntities1();

            return(_dbcontext.AccountBook.ToList());
        }