Exemple #1
0
 private void btnUpdateReview_Click(object sender, EventArgs e)
 {
     if (!txtReBody.Text.Equals(dr.Cells["Re_Comment"].Value.ToString()))
     {
         if (rDao.UpdateReview((int)dr.Cells["re_ID"].Value, txtReBody.Text))
         {
             MessageBox.Show("답글 달기에 성공 했습니다.");
             this.Close();
         }
     }
 }
        public ActionResult UpdateReview(ReviewVM viewModel)
        {
            ActionResult response;

            //check to see if logged in
            if (Session["RoleID"] != null)
            {
                //if logged in, check the users permissions
                if (Session["UserID"] != null && (int)Session["UserID"] == viewModel.Review.UserID || (int)Session["RoleID"] == 4 || (int)Session["RoleID"] == 6)
                {
                    //if allowed, check the model state
                    if (ModelState.IsValid)
                    {
                        //if model is valid, map review, then access database
                        try
                        {
                            //map form, send to database
                            ReviewDO reviewDO = _ReviewMapper.MapPOtoDO(viewModel.Review);
                            _ReviewDataAccess.UpdateReview(reviewDO);

                            //redirect to review details to show changes
                            response = RedirectToAction("ReviewDetails", "Review", new { id = viewModel.Review.ReviewID });
                        }
                        catch (Exception ex)
                        {
                            //log error
                            _Logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex);
                            response = RedirectToAction("Error", "Home");
                        }
                        finally { }
                    }
                    else
                    {
                        //if model is not valid, return to the form
                        response = View(viewModel);
                    }
                }
                else
                {
                    //if not allowed, redirect to login page
                    response = RedirectToAction("Login", "Account");
                }
            }
            else
            {
                //if not logged in, redirect to login page
                response = RedirectToAction("Login", "Account");
            }

            return(response);
        }
        public bool EditReview(Review review)
        {
            // create new instance of ReviewDAO
            ReviewDAO dataService = new ReviewDAO();


            if (dataService.UpdateReview(review))
            {
                return(true);
            }

            else
            {
                return(false);
            }
        }