Beispiel #1
0
        public ActionResult CreatConversation()
        {
            var iduser = Convert.ToInt32(Session["PasgoID"]);

            if (System.DateTime.Now < System.DateTime.Today.AddHours(8) || System.DateTime.Now > System.DateTime.Today.AddHours(20))
            {
                TempData["Failed"] = "Hệ thống CSKH hiện đang nghỉ, xin vui lòng liên hệ thời gian làm việc 8:00 - 20:00.";
                return(RedirectToAction("Chat", "ManageAccount"));
            }
            if (CheckUserAuthorize() == true)
            {
                //add exception
                var result = db.AddConversation(iduser).ToList().ElementAt(0);
                if (Convert.ToInt32(result) != 0)
                {
                    TempData["Success"] = "Hội thoại đã được thiết lập!";
                    db.SaveMessage(Convert.ToInt32(result), false, "Xin chào, tôi có thể giúp gì cho bạn?");
                }
                else
                {
                    TempData["Failed"] = "Hệ thống quá tải, xin vui lòng thử lại sau!";
                }
                return(RedirectToAction("Chat", "ManageAccount"));
            }
            return(View("Index", "Home"));
        }