Пример #1
0
        public string GetLoanByCustomer(string customerName)
        {
            using (LoansDatabaseEntities entities = new LoansDatabaseEntities())
            {
                var loansList = entities.Loans.Where(x => x.CustName.Contains(customerName)).ToList();

                if (loansList.Count > 0)
                {
                    return(JsonConvert.SerializeObject(loansList, Formatting.Indented,
                                                       new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                    }));
                }
                else
                {
                    return("Table empty");
                }
            }
        }
Пример #2
0
        public string GetAllLoans()
        {
            using (LoansDatabaseEntities entities = new LoansDatabaseEntities())
            {
                var loansList = (from f in entities.Loans
                                 select f).ToList <Loan>();


                if (loansList.Count > 0)
                {
                    return(JsonConvert.SerializeObject(loansList, Formatting.Indented,
                                                       new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                    }));
                }
                else
                {
                    return("Table empty");
                }
            }
        }