public virtual void DeleteShopComment(ShopComment comment) { ISession session = this._sessionManager.OpenSession(); NHibernate.ITransaction tx = session.BeginTransaction(); try { session.Delete(comment); tx.Commit(); session.Close(); } catch (Exception ex) { tx.Rollback(); throw new Exception("Unable to delete Shop comment" + "<br>" + ex.Message + "<br>" + ex.InnerException, ex); } }
private void btnPublish_Click(object sender, System.EventArgs e) { if(this.Page.IsValid) { Cuyahoga.Core.Domain.User tUser = this.Page.User.Identity as User; ShopComment tShopComment = new ShopComment(); tShopComment.DateCreated = DateTime.Now; tShopComment.DateModified = DateTime.Now; tShopComment.Message = TextParser.ShopCodeToHtml(this.txtMessage.Text, this._module); tShopComment.Title = this._origProduct.Title; tShopComment.ProductId = this._module.OrigShopProductId; tShopComment.Rating = int.Parse(this.ddnRating.SelectedValue); if(tUser != null) { tShopComment.UserId = tUser.Id; tShopComment.UserName = tUser.UserName; } else { tShopComment.UserId = 0; tShopComment.UserName = "******"; } this._module.SaveShopComment(tShopComment); // Update the original post this._origProduct.Comments++; this._module.SaveShopProduct(this._origProduct); Response.Redirect(String.Format("{0}/ShopViewProduct/{1}/ProductId/{2}", UrlHelper.GetUrlFromSection(this._module.Section), this._module.CurrentShopId, this._module.CurrentShopProductId)); } }