Esempio n. 1
0
        private List <Expensetype> getExpenses(HtmlNode row)
        {
            List <Expensetype> expensetypes = new List <Expensetype>();

            if (row != null)
            {
                foreach (HtmlNode divRow in row.ChildNodes)
                {
                    if (divRow.Name.Equals("div"))
                    {
                        //initialize new expensetype
                        Expensetype     expensetype = new Expensetype();
                        List <Expenses> expenseList = new List <Expenses>();
                        //get the title
                        HtmlNode h3Node = divRow.SelectSingleNode(".//h3");
                        if (h3Node != null)
                        {
                            expensetype.title = h3Node.InnerHtml;
                        }

                        foreach (HtmlNode descriptionWrapperNode in divRow.ChildNodes)
                        {
                            if (descriptionWrapperNode.Name.Equals("div"))
                            {
                                //initialize new expense
                                Expenses expense = new Expenses();

                                //get title
                                HtmlNode titleNode = descriptionWrapperNode.SelectSingleNode(".//span[1]");
                                if (titleNode != null)
                                {
                                    expense.title = titleNode.InnerHtml;
                                }

                                //get cost
                                HtmlNode costNode = descriptionWrapperNode.SelectSingleNode(".//span[2]");
                                if (costNode != null)
                                {
                                    double[] costs = Util.splitRentString(costNode.InnerHtml);
                                    expense.mincost = costs[0];
                                    expense.maxcost = costs[1];
                                }

                                //set property id
                                expense.property = myUrl.property;

                                //add to the list
                                expenseList.Add(expense);
                            }
                        }

                        expensetype.expensesList = expenseList;

                        //add to the list
                        expensetypes.Add(expensetype);
                    }
                }
            }
            return(expensetypes);
        }
Esempio n. 2
0
        private static int getExpenseTypeIdDb(Expensetype x)
        {
            if (x != null)
            {
                using (IDbConnection db = DBConnectionHelper.getConnection()){
                    Expensetype z = db.QueryFirstOrDefault <Expensetype>(
                        "select * from expense_type where name like @name",
                        new { name = x.Name });

                    if (z != null)
                    {
                        return(z.id);
                    }
                }
            }
            return(0);
        }