Exemplo n.º 1
0
        public ReviewList GetAll()
        {
            try
            {
                _list.Clear();
                Database db = new Database("Books");
                db.Command.CommandType = System.Data.CommandType.StoredProcedure;
                db.Command.CommandText = "tblReviewGETALL";
                DataTable dt = db.ExecuteQuery();
                //dgvStudent.DataSource = dt;
                foreach (DataRow dr in dt.Rows)
                {
                    Review s = new Review();
                    s.Initialize(dr);
                    s.InitializeBusinessData(dr);
                    s.IsDirty = false;
                    s.IsNew = false;
                    s.evtIsSavable += new IsSavableHandler(s_evtIsSavable);
                    _list.Add(s);
                }
            }

            catch(Exception ex)
            {
                throw;
            }

            return this;
        }
Exemplo n.º 2
0
 protected void btnPost_Click(object sender, EventArgs e)
 {
     Review br = new Review();
     User user = new User();
     user = (User)Session["User"];
     br.Title = txtTitle.Text;
     br.BookReview = txtBody.Text;
     br.UserID = user.ID;
     br.BookID = book.ID;
     book.Reviews.List.Add(br);
     book.Save();
     Response.Redirect("default.aspx");
 }
Exemplo n.º 3
0
        private Boolean Insert(Database db)
        {
            Review review = new Review();

            try
            {
                db.Command.Parameters.Clear();
                db.Command.CommandType = CommandType.StoredProcedure;
                db.Command.CommandText = "tblReviewINSERT";
                base.Initialize(db.Command, Guid.Empty);
                db.Command.Parameters.Add("@BookID", SqlDbType.UniqueIdentifier).Value = _BookID;
                db.Command.Parameters.Add("@UserID", SqlDbType.UniqueIdentifier).Value = _UserID;
                db.Command.Parameters.Add("@Title", SqlDbType.VarChar).Value = Title;
                db.Command.Parameters.Add("@BookReview", SqlDbType.VarChar).Value = _Review;
                db.ExecuteNonQueryWithTransaction();
                base.Initialize(db.Command);
                return true;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        public ReviewList GetByBookID(Guid BookID)
        {
            Database db = new Database("Books");
            try
            {
                db.Command.Parameters.Clear();
                db.Command.CommandType = CommandType.StoredProcedure;
                db.Command.CommandText = "tblReviewGETBYBOOKID";
                db.Command.Parameters.Add("@BookID", SqlDbType.UniqueIdentifier).Value = BookID;
                DataTable dt = db.ExecuteQuery();
                foreach (DataRow dr in dt.Rows)
                {
                    Review s = new Review();
                    s.Initialize(dr);
                    s.InitializeBusinessData(dr);
                    s.IsDirty = false;
                    s.IsNew = false;
                    s.evtIsSavable += new IsSavableHandler(s_evtIsSavable);
                    _list.Add(s);
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return this;
        }