Exemplo n.º 1
0
        public ActionResult DeletePledge(int id)
        {
            var fr = new FinancialRepository(Settings.Default.ConStr);

            fr.DeletePledge(id);
            return(Json(id));
        }
Exemplo n.º 2
0
        public ActionResult Pledge(Pledge pledge)
        {
            var fr = new FinancialRepository(Settings.Default.ConStr);

            fr.AddPledge(pledge);
            return(RedirectToAction("ViewMyActivity"));
        }
Exemplo n.º 3
0
        public ActionResult ViewMembers()
        {
            FinancialRepository  fr      = new FinancialRepository(Settings.Default.ConStr);
            IEnumerable <Member> members = fr.GetMembers();

            return(View(members));
        }
Exemplo n.º 4
0
        public EmitentModel(EmitentRepository emitentRepository, FinancialRepository financialRepository)
        {
            this._emitentRepository   = emitentRepository;
            this._financialRepository = financialRepository;

            Messenger.Default.Register <LoadEmitentListMessage>(this, async(msg) =>
            {
                IEnumerable <Emitent> emitentList = await this._emitentRepository.GetAll();

                Messenger.Default.Send <EmitentListLoadedMessage>(new EmitentListLoadedMessage()
                {
                    EmitentList = emitentList
                });
            });


            Messenger.Default.Register <LoadFinancialListMessage>(this, async(msg) =>
            {
                IEnumerable <Financial> financialList = await this._financialRepository.GetByEmitentId(msg.EmitentId);

                Messenger.Default.Send <FinancialListLoadedMessage>(new FinancialListLoadedMessage()
                {
                    FinancialList = financialList
                });
            });

            Messenger.Default.Register <SaveEmitentMessage>(this, (msg) =>
            {
                Task <string> task = null;

                if (msg.Emitent.Id != 0)
                {
                    task = this._emitentRepository.Update(msg.Emitent);
                }
            });

            Messenger.Default.Register <SaveFinancialMessage>(this, (msg) =>
            {
                Task <string> task = null;

                if (msg.Financial.Id != 0)
                {
                    task = this._financialRepository.Update(msg.Financial);
                }

                if (msg.Financial.Id == 0)
                {
                    task = this._financialRepository.Create(msg.Financial);
                }

                task.ContinueWith(t =>
                {
                    Messenger.Default.Send <SaveFinancialResultMeassage>(new SaveFinancialResultMeassage()
                    {
                        Result = t.Result
                    });
                });
            });
        }
Exemplo n.º 5
0
        public ActionResult UpdatePledge(int amount, int id)
        {
            var fr = new FinancialRepository(Settings.Default.ConStr);

            fr.UpdatePledge(amount, id);
            Pledge  pledge = fr.GetPledge(id);
            decimal a      = pledge.Amount;

            return(Json(a, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public void Test_Load()
        {
            var data = new List <OHLCV>();

            var factory = new SSDConnectionFactory(@"STEVE-PC\SQL_SSD", "Forexite");

            var repo = new FinancialRepository(factory);

            // CANNOT ACTUALLY INSERT
            //repo.Insert(Periods.OneMinute, new Pair(Symbol.NotSet, Symbol.NotSet), data);
        }
Exemplo n.º 7
0
        public ActionResult AddExpense(Expense expense)
        {
            if (expense.Name == null)
            {
                return(RedirectToAction("addexpense"));
            }
            var repo = new FinancialRepository(Settings.Default.ConStr);

            repo.AddExpense(expense);
            TempData["Notify"] = $"{expense.Name} added to expenses";
            return(RedirectToAction("addexpense"));
        }
Exemplo n.º 8
0
        public ActionResult ViewMonthlyPayments(int expenseId, string expenseName)
        {
            ViewBag.expensename = expenseName;
            FinancialRepository                  fr = new FinancialRepository(Settings.Default.ConStr);
            IEnumerable <MonthlyPayment>         monthlyPayments = fr.GetMonthlyPaymentsByExpenseId(expenseId);
            IEnumerable <MonthlyPaymentWithName> mpwn            = monthlyPayments.Select(mp => new MonthlyPaymentWithName
            {
                Amount = mp.Amount,
                Name   = mp.Member.FirstName + " " + mp.Member.LastName,
                Count  = mp.Count.Value
            });

            return(View(mpwn));
        }
Exemplo n.º 9
0
        public ActionResult ViewPledges(int expenseId, string expenseName)
        {
            ViewBag.expensename = expenseName;
            FinancialRepository          fr       = new FinancialRepository(Settings.Default.ConStr);
            IEnumerable <Pledge>         payments = fr.GetPledgesByExpenseId(expenseId);
            IEnumerable <PledgeWithName> pwn      = payments.Select(p => new PledgeWithName
            {
                Amount = p.Amount,
                Date   = p.Date,
                Name   = p.Member.FirstName + " " + p.Member.LastName
            });

            return(View(pwn));
        }
Exemplo n.º 10
0
        public ActionResult ViewShulExpenses()
        {
            var fr = new FinancialRepository(Settings.Default.ConStr);
            IEnumerable <Expense>     expenses     = fr.GetExpensesWithPaps();
            IEnumerable <ExpensePlus> expensesPlus = expenses.Select(e => new ExpensePlus
            {
                Id             = e.Id,
                Name           = e.Name,
                Cost           = e.Cost,
                TotalDonations = e.Payments.Sum(p => p.Amount),
                TotalPledges   = e.Pledges.Sum(p => p.Amount),
                Date           = e.Date
            });

            return(View(expensesPlus));
        }
Exemplo n.º 11
0
        private void SendEmail(Member m, Response r, int expenseId, int amount)
        {
            FinancialRepository fr      = new FinancialRepository(Settings.Default.ConStr);
            Expense             expense = fr.GetExpenseByExpenseId(expenseId);
            var fromAddress             = new MailAddress("*****@*****.**", "Beis Medrash of Jackson");
            var toAddress = new MailAddress(m.Email, m.FirstName + " " + m.LastName);

            string fromPassword = "******";
            string subject      = "Your Donation";
            string body         = $"Hi {m.FirstName},\n\n";

            if (r.Status == "Approved")
            {
                body += $"Thank you for your payment of ${amount}.00 towards {expense.Name}.\n";
            }
            else if (r.Status == "Error")
            {
                body += $"There was an error with your payment of ${amount}.00 towards {expense.Name}.\n{r.Error}\n";
            }
            else if (r.Status == "Declined")
            {
                body += $"Your payment of ${amount}.00 towards {expense.Name} has been declined.\n{r.Error}\n";
            }
            body += $"Reference Number: {r.RefNum}";
            var smtp = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body
            })
            {
                smtp.Send(message);
            }
        }
Exemplo n.º 12
0
        public ActionResult ViewMyActivity()
        {
            var    repo   = new VerifyRepository(Settings.Default.ConStr);
            Member member = repo.GetByEmail(User.Identity.Name);

            if (member == null)
            {
                return(RedirectToAction("ViewExpenses"));
            }
            var fr = new FinancialRepository(Settings.Default.ConStr);
            IEnumerable <Payment>         payments        = fr.GetPaymentsByMemberId(member.Id);
            IEnumerable <Pledge>          pledges         = fr.GetPledgesByMemberId(member.Id);
            IEnumerable <MonthlyPayment>  monthlyPayments = fr.GetMonthlyPaymentsByMemberId(member.Id);
            IEnumerable <PaymentWithName> pwn             = payments.Select(p => new PaymentWithName
            {
                Amount = p.Amount,
                Date   = p.Date,
                Name   = p.Expense.Name
            });
            IEnumerable <PledgeWithName> plwn = pledges.Select(p => new PledgeWithName
            {
                Id     = p.Id,
                Amount = p.Amount,
                Date   = p.Date,
                Name   = p.Expense.Name
            });
            IEnumerable <MonthlyPaymentWithName> mpwn = monthlyPayments.Select(mp => new MonthlyPaymentWithName
            {
                Amount = mp.Amount,
                Name   = mp.Expense.Name,
                Count  = mp.Count.Value
            });
            PaymentsAndPledges paps = new PaymentsAndPledges
            {
                Payments        = pwn,
                Pledges         = plwn,
                MonthlyPayments = mpwn
            };

            return(View(paps));
        }
Exemplo n.º 13
0
        public ActionResult GetById(int id)
        {
            FinancialRepository          fr              = new FinancialRepository(Settings.Default.ConStr);
            IEnumerable <Payment>        payments        = fr.GetPaymentsByMemberId(id);
            IEnumerable <Pledge>         pledges         = fr.GetPledgesByMemberId(id);
            IEnumerable <MonthlyPayment> monthlyPayments = fr.GetMonthlyPaymentsByMemberId(id);
            Member m = fr.GetMember(id);
            IEnumerable <PaymentWithName> pwn = payments.Select(p => new PaymentWithName
            {
                Amount = p.Amount,
                Date   = p.Date,
                Name   = p.Expense.Name
            });
            IEnumerable <PledgeWithName> plwn = pledges.Select(p => new PledgeWithName
            {
                Id     = p.Id,
                Amount = p.Amount,
                Date   = p.Date,
                Name   = p.Expense.Name
            });
            IEnumerable <MonthlyPaymentWithName> mpwn = monthlyPayments.Select(mp => new MonthlyPaymentWithName
            {
                Amount = mp.Amount,
                Name   = mp.Expense.Name,
                Count  = mp.Count.Value
            });
            PaymentsAndPledges paps = new PaymentsAndPledges
            {
                Payments        = pwn,
                Pledges         = plwn,
                MonthlyPayments = mpwn,
                Member          = m
            };

            return(View(paps));
        }
 public FinancialService()
 {
     repository = new();
 }
Exemplo n.º 15
0
        public ActionResult Index(int amount, string name, string street, string zipcode, string exp, string xCardNum, string xCVV, int memberId, int expenseId, int?count, string account, string routing, bool credit)
        {
            if (amount == 0 || string.IsNullOrEmpty(name) || memberId == 0 || expenseId == 0 || amount > 1000000 || name.Length > 100)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (credit)
            {
                if (string.IsNullOrEmpty(street) || string.IsNullOrEmpty(zipcode) || string.IsNullOrEmpty(exp) || string.IsNullOrEmpty(xCardNum) || string.IsNullOrEmpty(xCVV) || street.Length > 250 || zipcode.Length > 9 || exp.Length > 4)
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                if (string.IsNullOrEmpty(account) || string.IsNullOrEmpty(routing))
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            string command = credit ? "cc:Sale" : "check:Sale";

            System.Collections.Specialized.NameValueCollection MyPost = new System.Collections.Specialized.NameValueCollection();
            MyPost.Add("xKey", "YehoshuaLevinDev_Test_12301258f0bf44f2a6fcf0e");
            MyPost.Add("xVersion", "4.5.5");
            MyPost.Add("xSoftwareName", "ylevin");
            MyPost.Add("xSoftwareVersion", " 1.4.2");
            MyPost.Add("xCommand", command);
            MyPost.Add("xName", name);
            MyPost.Add("xAmount", amount.ToString());
            if (credit)
            {
                MyPost.Add("xStreet", street);
                MyPost.Add("xZip", zipcode);
                MyPost.Add("xExp", exp);
                MyPost.Add("xCardNum", xCardNum);
                MyPost.Add("xCVV", xCVV);
            }
            else
            {
                MyPost.Add("xAccount", account);
                MyPost.Add("xRouting", routing);
            }


            System.Net.WebClient MyClient = new System.Net.WebClient();
            string MyResponse             = System.Text.Encoding.ASCII.GetString(MyClient.UploadValues("https://x1.cardknox.com/gateway", MyPost));

            // Response
            System.Collections.Specialized.NameValueCollection MyResponseData = HttpUtility.ParseQueryString(MyResponse);
            string MyStatus = "";

            if (MyResponseData.AllKeys.Contains("xStatus"))
            {
                MyStatus = MyResponseData["xStatus"];
            }
            string MyError = "";

            if (MyResponseData.AllKeys.Contains("xError"))
            {
                MyError = MyResponseData["xError"];
            }
            string MyRefNum = "";

            if (MyResponseData.AllKeys.Contains("xRefNum"))
            {
                MyRefNum = MyResponseData["xRefNum"];
            }
            string MyToken = "";

            if (MyResponseData.AllKeys.Contains("xToken"))
            {
                MyToken = MyResponseData["xToken"];
            }

            Response response = new Response
            {
                Status = MyStatus,
                RefNum = MyRefNum,
                Error  = MyError,
            };


            FinancialRepository fr = new FinancialRepository(Settings.Default.ConStr);

            if (MyStatus == "Approved")
            {
                Payment p = new Payment
                {
                    MemberId  = memberId,
                    ExpenseId = expenseId,
                    Amount    = amount,
                    Date      = DateTime.Today
                };
                fr.AddPayment(p);
            }
            Member member = fr.GetMember(memberId);

            SendEmail(member, response, expenseId, amount);
            count--;
            if (MyStatus == "Approved" && count != null && credit)
            {
                MonthlyPayment mp = new MonthlyPayment
                {
                    Amount    = amount,
                    Token     = MyToken,
                    Name      = name,
                    MemberId  = memberId,
                    ExpenseId = expenseId,
                    Count     = count.Value,
                    Street    = street,
                    Zipcode   = zipcode,
                    Exp       = exp,
                    Credit    = true
                };
                fr.AddMonthlyPayment(mp);
            }
            else if (MyStatus == "Approved" && count != null && !credit)
            {
                MonthlyPayment mp = new MonthlyPayment
                {
                    Amount    = amount,
                    Token     = MyToken,
                    Name      = name,
                    MemberId  = memberId,
                    ExpenseId = expenseId,
                    Count     = count.Value,
                    Credit    = false
                };
                fr.AddMonthlyPayment(mp);
            }
            return(View(response));
        }
Exemplo n.º 16
0
        public ActionResult MonthlyPayments(string password)
        {
            if (password != "hardpassword")
            {
                return(RedirectToAction("Index", "Home"));
            }
            FinancialRepository          fr = new FinancialRepository(Settings.Default.ConStr);
            IEnumerable <MonthlyPayment> monthlyPayments = fr.GetMonthlyPayments();
            List <Response> responses = new List <Response>();

            foreach (MonthlyPayment mp in monthlyPayments)
            {
                string command = mp.Credit ? "cc:Sale" : "check:Sale";
                System.Collections.Specialized.NameValueCollection MyPost = new System.Collections.Specialized.NameValueCollection();
                MyPost.Add("xKey", "YehoshuaLevinDev_Test_12301258f0bf44f2a6fcf0e");
                MyPost.Add("xVersion", "4.5.5");
                MyPost.Add("xSoftwareName", "ylevin");
                MyPost.Add("xSoftwareVersion", "1.4.2");
                MyPost.Add("xCommand", "cc:Sale");
                MyPost.Add("xAmount", mp.Amount.ToString());
                MyPost.Add("xToken", mp.Token);
                MyPost.Add("xName", mp.Name);
                if (mp.Credit)
                {
                    MyPost.Add("xStreet", mp.Street);
                    MyPost.Add("xZip", mp.Zipcode);
                    MyPost.Add("xExp", mp.Exp);
                }

                System.Net.WebClient MyClient = new System.Net.WebClient();
                string MyResponse             = System.Text.Encoding.ASCII.GetString(MyClient.UploadValues("https://x1.cardknox.com/gateway", MyPost));
                // Response
                System.Collections.Specialized.NameValueCollection MyResponseData = HttpUtility.ParseQueryString(MyResponse);
                string MyStatus = "";
                if (MyResponseData.AllKeys.Contains("xStatus"))
                {
                    MyStatus = MyResponseData["xStatus"];
                }
                string MyError = "";
                if (MyResponseData.AllKeys.Contains("xError"))
                {
                    MyError = MyResponseData["xError"];
                }
                string MyRefNum = "";
                if (MyResponseData.AllKeys.Contains("xRefNum"))
                {
                    MyRefNum = MyResponseData["xRefNum"];
                }

                Response response = new Response
                {
                    Status = MyStatus,
                    RefNum = MyRefNum,
                    Error  = MyError
                };

                if (MyStatus == "Approved")
                {
                    Payment p = new Payment
                    {
                        MemberId  = mp.MemberId,
                        ExpenseId = mp.ExpenseId,
                        Amount    = mp.Amount,
                        Date      = DateTime.Today
                    };
                    fr.AddPayment(p);
                    fr.UpdateMonthlyPayment(mp.Id);
                }

                Member member = fr.GetMember(mp.MemberId);
                SendEmail(member, response, mp.ExpenseId, mp.Amount);
                responses.Add(new Response
                {
                    Status = MyStatus,
                    RefNum = MyRefNum,
                    Error  = MyError
                });
            }

            return(View(responses));
        }