Example #1
0
        public List <Review> GetReviewInvitesByUserId(int id)
        {
            CompanyContext cc = new CompanyContext();

            List <Review> reviews = new List <Review>();
            string        query   = "SELECT * FROM Review where User_Id = " + id + " AND IsInvite = true";

            using (var conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (var cmd = new SqlCommand(query, conn))
                {
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                int    userid = (int)reader["User_Id"];
                                Review review = new Review()
                                {
                                    Function  = (string)reader["Function"],
                                    StartDate = (DateTime)reader["StartDate"],
                                    EndDate   = (DateTime)reader["EndDate"],
                                    Company   = cc.GetCompanyById((int)reader["Company_Id"]),
                                };

                                AccountContext _accountContext = new AccountContext();
                                Account        account         = _accountContext.GetAccountById(userid);

                                review.Account = account;

                                reviews.Add(review);
                            }
                        }
                    }
                }



                return(reviews);
            }
        }
Example #2
0
        public List <Review> GetReviewsById(int id)
        {
            List <Review> reviews = new List <Review>();
            string        query   = "SELECT * FROM Review where User_Id = " + id + "";

            using (var conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (var cmd = new SqlCommand(query, conn))
                {
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                int    userid = (int)reader["User_Id"];
                                Review review = new Review()
                                {
                                    Function    = (string)reader["Function"],
                                    StartDate   = (DateTime)reader["StartDate"],
                                    EndDate     = (DateTime)reader["EndDate"],
                                    Overall     = (int)reader["Overall"],
                                    Explanation = (string)reader["Explanation"],
                                };

                                AccountContext _accountContext = new AccountContext();
                                Account        account         = _accountContext.GetAccountById(userid);

                                review.Account = account;

                                reviews.Add(review);
                            }
                        }
                    }
                }



                return(reviews);
            }
        }