Exemplo n.º 1
0
        public string Info()
        {
            var    userId      = GetUserId();
            var    groupId     = Convert.ToInt32(Context.Parameters["GroupId"]);
            var    paymentId   = Context.Parameters["Id"];
            string uID         = userId.ToString();
            string gID         = Convert.ToString(Context.Parameters["GroupId"]);
            string date        = DateTime.Today.ToString();
            string description = Data.Description;
            string currency    = Data.Currency;
            string text        = EmailService.Text(Payers.ToList(), Debtors.ToList(), uID, gID, date, description, currency);

            return(text);
        }
Exemplo n.º 2
0
        public List <Loan> GetLoans(string userID)
        {
            List <Loan> loans = null;

            try
            {
                using (var context = new DebtyDBContext())
                {
                    var loanss = (from loan in context.Loans
                                  join creditor in context.Persons on loan.Creditor.Id equals creditor.Id
                                  where loan.Creditor.Id == userID
                                  select new
                    {
                        loanID = loan.LoanID,
                        loanName = loan.LoanName,
                        loanDesc = loan.LoanDesc,
                        loanDate = loan.LoanDate,
                        deadline = loan.Deadline,
                        loanAmount = loan.LoanAmount,
                        Creditor = new Creditor {
                            PersonID = loan.Creditor.Id, FirstName = creditor.FirstName, LastName = creditor.LastName
                        },
                    }).ToList();

                    var debtors = (from dl in context.DebtorLoans
                                   join debtor in context.Persons on dl.DebtorID equals debtor.Id
                                   select new
                    {
                        loanID = dl.LoanID,
                        debtor = new Debtor {
                            FirstName = debtor.FirstName, LastName = debtor.LastName
                        }
                    } into D
                                   group D by D.loanID into Debtors
                                   select new
                    {
                        loanID = Debtors.Key,
                        Debtors = Debtors.ToList()
                    }).ToList();

                    loans = (from loan in loanss
                             join debtor in debtors on loan.loanID equals debtor.loanID
                             select new Loan
                    {
                        LoanID = loan.loanID,
                        LoanName = loan.loanName,
                        LoanDesc = loan.loanDesc,
                        LoanDate = loan.loanDate,
                        Deadline = loan.deadline,
                        LoanAmount = loan.loanAmount,
                        Creditor = loan.Creditor,
                        Debtors = debtor.Debtors.Select(x => x.debtor).ToList()
                    }).ToList();

                    return(loans);
                }
            }
            catch (Exception ex)
            {
                return(loans.DefaultIfEmpty().ToList());
            }
        }