Exemplo n.º 1
0
        public virtual ActionResult Feed(string id)
        {
            var items = new List <SyndicationItem>();

            using (SkillTreeHomeworkEntities context = new SkillTreeHomeworkEntities())
            {
                var query = from item in context.AccountBook
                            orderby item.Dateee descending
                            select item;
                var topTen = query.Take(10);
                foreach (var content in topTen)
                {
                    string feedTitle = "";
                    if (content.Categoryyy == 0)
                    {
                        feedTitle = "支出|";
                    }
                    else
                    {
                        feedTitle = "收入|";
                    }
                    var helper = new UrlHelper(this.Request.RequestContext);
                    var url    = helper.Action("Index", "Home", new { }, Request.IsSecureConnection ? "https" : "http");

                    var feedPackageItem = new SyndicationItem(feedTitle + content.Remarkkk.ToString(), content.Amounttt.ToString("N0"), new Uri(url));
                    feedPackageItem.PublishDate = content.Dateee;
                    items.Add(feedPackageItem);
                }
                return(new RssActionResult("我的記帳本 RSS", items));
            }
        }
Exemplo n.º 2
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.db != null)
         {
             this.db.Dispose();
             this.db = null;
         }
     }
 }
Exemplo n.º 3
0
        public IEnumerable <MoneyTemplateViewModels> GetItemList()
        {
            List <MoneyTemplateViewModels> moneyTemplateViewModels = new List <MoneyTemplateViewModels>();
            var Conn = new SkillTreeHomeworkEntities().Database.Connection;

            string strSQL = "select Id id, Categoryyy category, Amounttt money, Dateee date, Remarkkk description " +
                            " from AccountBook " +
                            " order by Dateee ";

            moneyTemplateViewModels = Conn.Query <MoneyTemplateViewModels>(strSQL, null).ToList();

            return(moneyTemplateViewModels);
        }
Exemplo n.º 4
0
 public IEnumerable <MoneyViewModel> GetList()
 {
     using (var _accountData = new SkillTreeHomeworkEntities())
     {
         return((from c in _accountData.AccountBook
                 select new MoneyViewModel
         {
             SelectedTypes = c.Categoryyy,
             Date = c.Dateee,
             Money = c.Amounttt,
             Note = c.Remarkkk
         }).ToList());
     }
 }
Exemplo n.º 5
0
 public void save(MoneyData viewModel)
 {
     using (SkillTreeHomeworkEntities db = new SkillTreeHomeworkEntities())
     {
         AccountBook accountBook = new AccountBook
         {
             Dateee     = viewModel.time,
             Amounttt   = (int)viewModel.money,
             Categoryyy = viewModel.moneyType,
             Remarkkk   = viewModel.remark,
             Id         = Guid.NewGuid()
         };
         db.AccountBook.Add(accountBook);
         db.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public IEnumerable <MoneyData> getDataLists()
 {
     using (SkillTreeHomeworkEntities db = new SkillTreeHomeworkEntities())
     {
         int i = 0;
         foreach (AccountBook accountBook in db.AccountBook.OrderBy(s => s.Dateee))
         {
             MoneyData moneyData = new MoneyData
             {
                 number    = ++i,
                 moneyType = accountBook.Categoryyy,
                 time      = accountBook.Dateee,
                 money     = accountBook.Amounttt,
             };
             yield return(moneyData);
         }
     }
 }
Exemplo n.º 7
0
        public ActionResult Index(AccountContentViewModel data)
        {
            if (ModelState.IsValid)
            {
                var accountBookNew = new AccountBook
                {
                    Id         = Guid.NewGuid(),
                    Categoryyy = data.accountCategory,
                    Amounttt   = (int)data.accountFee,
                    Dateee     = data.accountDate,
                    Remarkkk   = data.accountNote
                };

                SkillTreeHomeworkEntities db = new SkillTreeHomeworkEntities();
                db.AccountBook.Add(accountBookNew);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }
            return(View(data));
        }
Exemplo n.º 8
0
        public ActionResult ShowAccountContent()
        {
            List <AccountContentViewModel> accountList = new List <AccountContentViewModel>();

            //accountList.Add(new AccountContentViewModel { accountCategory = "支出", accountDate = new DateTime(2016, 1, 1), accountFee = 300, accountNote = "" });
            //accountList.Add(new AccountContentViewModel { accountCategory = "支出", accountDate = new DateTime(2016, 1, 2), accountFee = 1600, accountNote = "" });
            //accountList.Add(new AccountContentViewModel { accountCategory = "支出", accountDate = new DateTime(2016, 1, 3), accountFee = 800, accountNote = "" });
            using (SkillTreeHomeworkEntities context = new SkillTreeHomeworkEntities())
            {
                var query = from item in context.AccountBook
                            orderby item.Dateee descending
                            select item;
                foreach (var item in query)
                {
                    accountList.Add(new AccountContentViewModel {
                        accountCategory = item.Categoryyy, accountFee = item.Amounttt, accountDate = item.Dateee, accountNote = item.Remarkkk
                    });
                }
            }
            return(View(accountList));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 取得記帳本全部資料
        /// </summary>
        /// <returns></returns>
        public static List <SpendingViewModels> GetAccountBookList()
        {
            SkillTreeHomeworkEntities _db        = new SkillTreeHomeworkEntities();
            List <SpendingViewModels> ViewModles = new List <SpendingViewModels>();

            var AccountBookList     = _db.AccountBook.ToList();
            SpendingViewModels item = new SpendingViewModels();

            foreach (var VARIABLE in AccountBookList)
            {
                item = new SpendingViewModels
                {
                    Category = VARIABLE.Categoryyy.ToString(),
                    Amount   = VARIABLE.Amounttt,
                    Day      = VARIABLE.Dateee,
                    Remarks  = VARIABLE.Remarkkk
                };
                ViewModles.Add(item);
            }

            return(ViewModles);
        }
Exemplo n.º 10
0
 // GET: Admin/Admin
 public ActionResult Index()
 {
     if (User.Identity.IsAuthenticated)
     {
         List <AccountContentViewModel> accountList = new List <AccountContentViewModel>();
         using (SkillTreeHomeworkEntities context = new SkillTreeHomeworkEntities())
         {
             var query = from item in context.AccountBook
                         orderby item.Dateee descending
                         select item;
             foreach (var item in query)
             {
                 accountList.Add(new AccountContentViewModel {
                     accountCategory = item.Categoryyy, accountFee = item.Amounttt, accountDate = item.Dateee, accountNote = item.Remarkkk
                 });
             }
         }
         return(View(accountList));
     }
     else
     {
         return(RedirectToAction("Index", new { controller = "Home", area = "" }));
     }
 }
Exemplo n.º 11
0
 public AccountBookRepository()
 {
     this.db = new SkillTreeHomeworkEntities();
 }
Exemplo n.º 12
0
 public Repository()
 {
     _SkillEntities = new SkillTreeHomeworkEntities();
     Dbset          = _SkillEntities.Set <T>();
 }
Exemplo n.º 13
0
 public AccountingService()
 {
     _db = new SkillTreeHomeworkEntities();
 }