Exemple #1
0
        public ActionResult Contact(String ho_ten, String mail, String noi_dung)
        {
            if (noi_dung == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblKhachHang kh = (tblKhachHang)Session["KH"];

            if (kh == null)
            {
                if (ho_ten == null || mail == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
            }
            if (noi_dung.Length >= 500)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblTinNhan tn = new tblTinNhan();

            if (kh == null)
            {
                tn.ho_ten = ho_ten;
                tn.mail   = mail;
            }
            else
            {
                tn.ma_kh = kh.ma_kh;
            }
            tn.noi_dung = noi_dung;
            tn.ngay_gui = DateTime.Now;
            try
            {
                db.tblTinNhans.Add(tn);
                db.SaveChanges();
                ModelState.AddModelError("", "Gửi ticket thành công !");
            }
            catch
            {
                ModelState.AddModelError("", "Có lỗi xảy ra!");
            }
            return(View());
        }
Exemple #2
0
        public ActionResult SMS(String ho_ten, String mail, String noi_dung)
        {
            if (noi_dung == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblKhachHang kh = (tblKhachHang)Session["KH"];

            if (kh == null)
            {
                if (ho_ten == null || mail == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
            }
            if (noi_dung.Length >= 500)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblTinNhan tn = new tblTinNhan();

            if (kh == null)
            {
                tn.ho_ten = ho_ten;
                tn.mail   = mail;
            }
            else
            {
                tn.ma_kh = kh.ma_kh;
            }
            tn.noi_dung = noi_dung;
            try
            {
                db.tblTinNhans.Add(tn);
                db.SaveChanges();
                ViewBag.result = "success";
            }
            catch
            {
                ViewBag.result = "error";
            }
            return(View());
        }