コード例 #1
0
        public ActionResult History(int contribId)
        {
            var mgr           = new SimchaFundManager(Properties.Settings.Default.ConStr);
            var deposits      = mgr.GetDepositsById(contribId);
            var contributions = mgr.GetContributionsById(contribId);

            IEnumerable <Transaction> transactions = deposits.Select(d => new Transaction
            {
                Action = "Deposit",
                Amount = d.Amount,
                Date   = d.Date
            }).Concat(contributions.Select(c => new Transaction
            {
                Action = "Contribution for the " + c.SimchaName + " simcha",
                Amount = -c.Amount,
                Date   = c.Date
            })).OrderByDescending(t => t.Date);

            var vm = new HistoryViewModel();

            vm.Transactions = transactions;

            //List<string> st = new List<string>();
            //st.Add("1");
            //st.Add("10");
            //st.Add("51");

            //IEnumerable<int> nums = st.MySelect<string, int>(s => int.Parse(s));

            return(View(vm));
        }
コード例 #2
0
        public ActionResult History(int contribId)
        {
            var mgr = new SimchaFundManager(Properties.Settings.Default.ConStr);
            IEnumerable <Deposit>      deposits      = mgr.GetDepositsById(contribId);
            IEnumerable <Contribution> contributions = mgr.GetContributionsById(contribId);

            IEnumerable <Transaction> transactions = deposits.Select(d => new Transaction
            {
                Action = "Deposit",
                Amount = d.Amount,
                Date   = d.Date
            }).Concat(contributions.Select(c => new Transaction
            {
                Action = $"Contribution for the {c.SimchaName} simcha",
                Amount = -c.Amount,
                Date   = c.Date
            })).OrderByDescending(t => t.Date);

            var vm = new HistoryViewModel
            {
                Transactions = transactions
            };

            return(View(vm));
        }
コード例 #3
0
        public ActionResult New(Simcha simcha)
        {
            var mgr = new SimchaFundManager(Properties.Settings.Default.ConStr);

            mgr.AddSimcha(simcha);
            TempData["Message"] = $"New Simcha Created! Id: {simcha.Id}";
            return(RedirectToAction("index"));
        }
コード例 #4
0
        public ActionResult UpdateContributions(List <ContributionInclusion> contributors, int simchaId)
        {
            var mgr = new SimchaFundManager(Properties.Settings.Default.ConStr);

            mgr.UpdateSimchaContributions(simchaId, contributors);
            TempData["Message"] = "Simcha updated successfully";
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public IActionResult New(Simcha simcha)
        {
            var mgr = new SimchaFundManager(_connectionString);

            mgr.AddSimcha(simcha);
            TempData["Message"] = $"New Simcha Created! Id: {simcha.Id}";
            return(RedirectToAction("index"));
        }
コード例 #6
0
        public ActionResult Edit(Contributor contributor)
        {
            var mgr = new SimchaFundManager(Properties.Settings.Default.ConStr);

            mgr.UpdateContributor(contributor);
            TempData["Message"] = "Contributor updated successfully";
            return(RedirectToAction("Index"));
        }
コード例 #7
0
        public IActionResult Deposit(Deposit deposit)
        {
            var mgr = new SimchaFundManager(_connectionString);

            mgr.AddDeposit(deposit);
            TempData["message"] = "Deposit successfully recorded";
            return(RedirectToAction("Index"));
        }
コード例 #8
0
        public IActionResult Edit(Contributor contributor)
        {
            var mgr = new SimchaFundManager(_connectionString);

            mgr.UpdateContributor(contributor);
            TempData["Message"] = "Contributor updated successfully";
            return(RedirectToAction("Index"));
        }
コード例 #9
0
        public ActionResult Deposit(Deposit deposit)
        {
            var mgr = new SimchaFundManager(Properties.Settings.Default.ConStr);

            mgr.AddDeposit(deposit);
            TempData["Message"] = "Deposit of $" + deposit.Amount + " recorded successfully";
            return(RedirectToAction("Index"));
        }
コード例 #10
0
        public ActionResult New(string name, DateTime date)
        {
            var    mgr    = new SimchaFundManager(Properties.Settings.Default.ConStr);
            Simcha simcha = new Simcha {
                Name = name, Date = date
            };

            mgr.AddSimcha(simcha);
            TempData["Message"] = "New Simcha Created! Id: " + simcha.Id;
            return(RedirectToAction("index"));
        }
コード例 #11
0
        public IActionResult Index()
        {
            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"];
            }
            var vm  = new ContributorsIndexViewModel();
            var mgr = new SimchaFundManager(_connectionString);

            vm.Contributors = mgr.GetContributors();
            return(View(vm));
        }
コード例 #12
0
        public ActionResult Index()
        {
            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"];
            }
            var vm  = new ContributorsIndexViewModel();
            var mgr = new SimchaFundManager(Properties.Settings.Default.ConStr);

            vm.Contributors = mgr.GetContributors();
            return(View(vm));
        }
コード例 #13
0
        public IActionResult Index()
        {
            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"];
            }
            var mgr       = new SimchaFundManager(_connectionString);
            var viewModel = new SimchaIndexViewModel();

            viewModel.TotalContributors = mgr.GetContributorCount();
            viewModel.Simchas           = mgr.GetAllSimchas();
            return(View(viewModel));
        }
コード例 #14
0
        public ActionResult Index()
        {
            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"];
            }
            var mgr       = new SimchaFundManager(Properties.Settings.Default.ConStr);
            var viewModel = new SimchaIndexViewModel();

            viewModel.TotalContributors = mgr.GetContributorCount();
            viewModel.Simchas           = mgr.GetAllSimchas();
            return(View(viewModel));
        }
コード例 #15
0
        public ActionResult Contributions(int simchaId)
        {
            var    mgr    = new SimchaFundManager(Properties.Settings.Default.ConStr);
            Simcha simcha = mgr.GetAllSimchas().First(s => s.Id == simchaId); //this should be done in the database
            IEnumerable <SimchaContributor> contributors = mgr.GetSimchaContributorsEasy(simchaId);

            var viewModel = new ContributionsViewModel
            {
                Contributors = contributors,
                Simcha       = simcha
            };

            return(View(viewModel));
        }
コード例 #16
0
        public ActionResult History(int contribId)
        {
            var mgr = new SimchaFundManager(Properties.Settings.Default.ConStr);
            IEnumerable <Deposit>      deposits      = mgr.GetDepositsById(contribId);
            IEnumerable <Contribution> contributions = mgr.GetContributionsById(contribId);

            #region list way without select
            //List<Transaction> transactions2 = new List<Transaction>();
            //foreach (Deposit deposit in deposits)
            //{
            //    transactions2.Add(new Transaction
            //    {
            //        Action = "Deposit",
            //        Amount = deposit.Amount,
            //        Date = deposit.Date
            //    });
            //}

            //foreach (Contribution c in contributions)
            //{
            //    transactions2.Add(new Transaction
            //    {
            //        Action = "Contribution for the " + c.SimchaName + " simcha",
            //        Amount = -c.Amount,
            //        Date = c.Date
            //    });
            //}

            //transactions2.OrderByDescending(t => t.Date);
            #endregion
            IEnumerable <Transaction> transactions = deposits.Select(d => new Transaction
            {
                Action = "Deposit",
                Amount = d.Amount,
                Date   = d.Date
            }).Concat(contributions.Select(c => new Transaction
            {
                Action = "Contribution for the " + c.SimchaName + " simcha",
                Amount = -c.Amount,
                Date   = c.Date
            })).OrderByDescending(t => t.Date);

            var vm = new HistoryViewModel();
            vm.Transactions = transactions;
            Contributor contributor = mgr.GetContributors().First(c => c.Id == contribId);
            vm.ContributorBalance = contributor.Balance;
            vm.ContributorName    = contributor.FirstName + " " + contributor.LastName;

            return(View(vm));
        }
コード例 #17
0
        public IActionResult Contributions(int simchaId)
        {
            var    mgr    = new SimchaFundManager(_connectionString);
            Simcha simcha = mgr.GetSimchaById(simchaId);
            IEnumerable <SimchaContributor> contributors = mgr.GetSimchaContributorsOneQuery(simchaId);

            var viewModel = new ContributionsViewModel
            {
                Contributors = contributors,
                Simcha       = simcha
            };

            return(View(viewModel));
        }
コード例 #18
0
        public ActionResult Contributions(int simchaId)
        {
            var    mgr    = new SimchaFundManager(Properties.Settings.Default.ConStr);
            Simcha simcha = mgr.GetSimchaById(simchaId);
            IEnumerable <SimchaContributor> contributors = mgr.GetSimchaContributorsEasy(simchaId);

            var viewModel = new ContributionsViewModel
            {
                Contributors = contributors,
                Simcha       = simcha
            };

            return(View(viewModel));
        }
コード例 #19
0
        public ActionResult New(Contributor contributor, decimal initialDeposit)
        {
            var mgr = new SimchaFundManager(Properties.Settings.Default.ConStr);

            mgr.AddContributor(contributor);
            var deposit = new Deposit
            {
                Amount        = initialDeposit,
                ContributorId = contributor.Id,
                Date          = contributor.Date
            };

            mgr.AddDeposit(deposit);
            TempData["Message"] = "New Contributor Created! Id: " + contributor.Id;
            return(RedirectToAction("index"));
        }
コード例 #20
0
        public IActionResult New(Contributor contributor, decimal initialDeposit)
        {
            var mgr = new SimchaFundManager(_connectionString);

            mgr.AddContributor(contributor);
            var deposit = new Deposit
            {
                Amount        = initialDeposit,
                ContributorId = contributor.Id,
                Date          = contributor.Date
            };

            mgr.AddDeposit(deposit);
            TempData["Message"] = $"New Contributor Created! Id: {contributor.Id}";
            return(RedirectToAction("index"));
        }