Пример #1
0
        public InvestmentNumbers GetInvestmentNumbers()
        {
            string userId = UserService.GetCurrentUserId();

            if (userId != null)
            {
                InvestmentNumbers singleItem = null;
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("dbo.Users_GetInvestmentNumbers", conn))
                    {
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@UserId", userId);
                        SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                        while (reader.Read())
                        {
                            singleItem = Mapper3(reader);
                        }
                    }
                    conn.Close();
                }
                return(singleItem);
            }
            return(null);
        }
Пример #2
0
        private InvestmentNumbers Mapper3(SqlDataReader reader)
        {
            InvestmentNumbers model = new InvestmentNumbers();
            int index = 0;

            model.Invested = reader.GetDouble(index++);
            model.Revenue  = reader.GetDouble(index++);

            return(model);
        }