public ActionResult Create(CR_ComentarioReview cr_comentarioreview) { if (ModelState.IsValid) { bool wasNotApproved = Extensions.ExtensionHelper.NotApproved(cr_comentarioreview.CR_Comentario); if (wasNotApproved) { cr_comentarioreview.ST_Id = 7; } else cr_comentarioreview.ST_Id = 1; db.SaveChanges<CR_ComentarioReview>(cr_comentarioreview); var user = db.UserProfile.Find(WebSecurity.CurrentUserId); CommentReview cmt = new CommentReview { Comments = cr_comentarioreview.CR_Comentario, Image = Url.Content(string.IsNullOrEmpty(user.Image) ? "~/Images/No_Profile.jpg" : user.Image), Name = user.Name }; if (Request.IsAjaxRequest()) { return Json(new { data = cmt }.SerializeToJson()); } return RedirectToAction("Index"); } ViewBag.RW_Id = new SelectList(db.RW_Reviews, "RW_Id", "RW_Comentario", cr_comentarioreview.RW_Id); ViewBag.ST_Id = new SelectList(db.ST_Estatus, "ST_Id", "ST_Descripcion", cr_comentarioreview.ST_Id); ViewBag.UserId = new SelectList(db.UserProfile, "UserId", "UserName", cr_comentarioreview.UserId); if (Request.IsAjaxRequest()) { return Json(new { error = true }.SerializeToJson()); } return View(cr_comentarioreview); }
public ActionResult Edit(CR_ComentarioReview cr_comentarioreview) { if (ModelState.IsValid) { db.Entry(cr_comentarioreview).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.RW_Id = new SelectList(db.RW_Reviews, "RW_Id", "RW_Comentario", cr_comentarioreview.RW_Id); ViewBag.ST_Id = new SelectList(db.ST_Estatus, "ST_Id", "ST_Descripcion", cr_comentarioreview.ST_Id); ViewBag.UserId = new SelectList(db.UserProfile, "UserId", "UserName", cr_comentarioreview.UserId); return View(cr_comentarioreview); }