protected void Button1_Click(object sender, EventArgs e) { try { using (var ctx = new RachnaDBContext()) { ProdComments ProdComments = new ProdComments(); int commentId = Convert.ToInt32(hdnProductCommentId.Value); ProdComments = ctx.ProdComments.ToList().Where(m => m.Comment_Id == commentId).FirstOrDefault(); if (ProdComments != null) { ProdComments.Comment_Status = ddlSorderStatus.Text; ProdComments.DateUpdated = DateTime.Now; ctx.Entry(ProdComments).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = "Comment Detail Updated Successfully and status set to " + ddlSorderStatus.Text; } } } catch (Exception ex) { pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = ex.Message; } }
public ActionResult ProductComments(string ProductId, string rating, string CustomerId, string likeunlike, string description) { int prdId = Convert.ToInt32(ProductId); int cusId = Convert.ToInt32(CustomerId); Product Product = context.Product.Include("ProductBanner").Where(m => m.Product_Id == prdId).FirstOrDefault(); Customers Customers = bCustomer.List().Where(m => m.Customer_Id == cusId).FirstOrDefault(); ProdComments Comments = new ProdComments() { Customer_Id = Customers.Customer_Id, Product_Id = Product.Product_Id, Comment_Status = eCommentStatus.Pending.ToString(), Customer_Name = Customers.Customers_FullName, Description = description, Product_Title = Product.Product_Title, Product_Banner = Product.ProductBanner.Where(m => m.Product_Id == Product.Product_Id).FirstOrDefault().Product_Banner_Photo, Rating = Convert.ToInt32(rating), LikeUnlike = (likeunlike == "like") ? 1 : 0, Store_Id = Product.Store_Id, DateCreated = DateTime.Now, DateUpdated = DateTime.Now }; context.ProdComments.Add(Comments); context.SaveChanges(); return(Redirect("/product/index?id=" + Product.Product_Id + "&title=" + Product.Product_Title)); }