//Thêm mới góp ý phản hồi theo khách hàng
        public JsonResult ThemMoiGopYPhanHoi(string khieunai, string gopy)
        {
            try
            {
                if (String.IsNullOrEmpty(khieunai) == true && String.IsNullOrEmpty(gopy) == true)
                {
                    return(Json(new { status = false }, JsonRequestBehavior.AllowGet));
                }
                string username = HttpContext.User.Identity.Name;
                if (username != null)
                {
                    //lấy id khách hang
                    var data = (from k in ctx.QC_KhachHang
                                where k.tendangnhap == username
                                select new { k.id }).FirstOrDefault();

                    QC_Gopy_KhieuNai obj = new QC_Gopy_KhieuNai();
                    obj.idkhachhang     = data.id;
                    obj.noidunggopy     = gopy;
                    obj.noidungkhieunai = khieunai;
                    obj.ngaygopy        = DateTime.Now;
                    ctx.QC_Gopy_KhieuNai.Add(obj);
                    ctx.SaveChanges();
                    var gopy_phanhoi = ctx.QC_Gopy_KhieuNai;
                    return(Json(new { status = true, obj }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { status = false }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Logs.WriteLog(ex);
                return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #2
0
 public ActionResult PhanHoiYKien(QC_Gopy_KhieuNai obj, string noidungphanhoi)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var data = ctx.QC_Gopy_KhieuNai.Where(x => x.id == obj.id).FirstOrDefault();
             data.ngayphanhoi      = DateTime.Now;
             data.noidungphanhoi   = noidungphanhoi;
             ctx.Entry(data).State = EntityState.Modified;
             int cn = ctx.SaveChanges();
             if (cn > 0)
             {
                 SetAlert("Phản hồi thành công", AlertType.Success);
                 return(RedirectToAction("Index", "QC_Gopy_KhieuNai"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm mới không thành công");
             }
             return(View("Index"));
         }
         return(View());
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
        public ActionResult GopYKhieuNai(QC_Gopy_KhieuNai obj)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (String.IsNullOrEmpty(obj.noidunggopy) == true && String.IsNullOrEmpty(obj.noidungkhieunai) == true)
                    {
                        return(Content("Lỗi!"));
                    }
                    string username = HttpContext.User.Identity.Name;
                    if (username != null)
                    {
                        //lấy id khách hang
                        var data = (from k in ctx.QC_KhachHang
                                    where k.tendangnhap == username
                                    select new { k.id }).FirstOrDefault();

                        obj.idkhachhang = data.id;
                        obj.ngaygopy    = DateTime.Now;
                        ctx.QC_Gopy_KhieuNai.Add(obj);
                        int cn = ctx.SaveChanges();
                        if (cn > 0)
                        {
                            SetAlert("Thêm mới thành công", AlertType.Success);
                            return(RedirectToAction("HienThiGopY", "TaiKhoan"));
                        }
                        else
                        {
                            ModelState.AddModelError("", "Thêm mới không thành công");
                        }
                        return(View("Index"));
                    }
                }
                return(View());
            }
            catch (Exception ex)
            {
                SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
                Logs.WriteLog(ex);
                return(View());
            }
        }