示例#1
0
        public ActionResult Create([Bind(Include = "PK_SEQ,USERNAME,TOKEN,STATUS")] USER uSER)
        {
            if (ModelState.IsValid)
            {
                db.USER.Add(uSER);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(uSER));
        }
示例#2
0
        public ActionResult Create([Bind(Include = "PK_SEQ,LESSION_FK,NAME,DESCRIPTION")] GROUP_CONTENT gROUP_CONTENT)
        {
            if (ModelState.IsValid)
            {
                db.GROUP_CONTENT.Add(gROUP_CONTENT);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gROUP_CONTENT));
        }
示例#3
0
        public ActionResult Create([Bind(Include = "PK_SEQ,NAME,IMAGE,DESCRIPTION,MENU")] LESSION lESSION)
        {
            if (ModelState.IsValid)
            {
                db.LESSION.Add(lESSION);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(lESSION));
        }
示例#4
0
        public ActionResult Create([Bind(Include = "PK_SEQ,STT,CONTENT_TEXT,TYPE,GROUP_CONTENT_FK")] CONTENT cONTENT)
        {
            if (ModelState.IsValid)
            {
                db.CONTENT.Add(cONTENT);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cONTENT));
        }
示例#5
0
        public ActionResult Create([Bind(Include = "PK_SEQ,TAG_NAME")] TAG tAG)
        {
            if (ModelState.IsValid)
            {
                db.TAG.Add(tAG);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tAG));
        }
示例#6
0
        public ActionResult Create([Bind(Include = "PK_SEQ,LESSON_FK,TAG_FK")] LESSION_TAG lESSION_TAG)
        {
            if (ModelState.IsValid)
            {
                db.LESSION_TAG.Add(lESSION_TAG);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(lESSION_TAG));
        }
示例#7
0
        public ActionResult Create([Bind(Include = "PK_SEQ,ANSWER_TEXT,ANSWER_USER_FK,QUESTION_FK,STATUS")] ANSWER aNSWER)
        {
            if (ModelState.IsValid)
            {
                db.ANSWER.Add(aNSWER);
                db.SaveChanges();
                NotifinewAnswer((int)aNSWER.QUESTION_FK);
                return(RedirectToAction("Index"));
            }

            return(View(aNSWER));
        }
示例#8
0
        public ActionResult Create([Bind(Include = "PK_SEQ,EN,VI,RELATE,ORDER,STATUS")] KEYWORD kEYWORD)
        {
            if (ModelState.IsValid)
            {
                char[] splitchar = { ' ' };
                kEYWORD.ORDER  = kEYWORD.VI.Trim().Split().Count();
                kEYWORD.STATUS = 1;
                db.KEYWORD.Add(kEYWORD);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(kEYWORD));
        }
示例#9
0
        public int CreateUser(OOPEZZ_DBEntities db, string PSID)
        {
            string fbtoken = AppInstance.getInstance().getFbPageToken();
            string url     = "https://graph.facebook.com/" + PSID +
                             "?fields=first_name,last_name,gender&access_token=" +
                             fbtoken;

            var request = (HttpWebRequest)WebRequest.Create(url);

            request.ContentType = "application/json";
            request.Method      = "GET";
            WebResponse response = request.GetResponse();
            string      result   = new StreamReader(response.GetResponseStream()).ReadToEnd();
            //UserAPITemplate userResponse =  new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<UserAPITemplate>(result);
            UserAPITemplate userResponse = JsonConvert.DeserializeObject <UserAPITemplate>(result);
            string          name         = Ulti.UnicodeDecode(userResponse.LastName + " " + userResponse.FirstName);
            USER            user         = new USER()
            {
                STATUS   = 1,
                TOKEN    = PSID,
                USERNAME = name
            };

            db.USER.Add(user);
            db.SaveChanges();

            return(user.PK_SEQ);
        }
示例#10
0
        //private void _lessonmenu(OOPEZZ_DBEntities db, BotMessageReceivedRequest botMessage)
        //{
        //    ///thua
        //    List<LESSION> lessionlist = db.LESSION.ToList();
        //    List<PayloadElements> listelement = new List<PayloadElements>();
        //    foreach (LESSION ls in lessionlist)
        //    {
        //        PayloadElements element = new PayloadElements()
        //        {
        //            title = ls.NAME,
        //            //image_url = ls.IMAGE,
        //            subtitle = ls.DESCRIPTION,

        //            buttons = new List<ResponseButtons>
        //            {
        //                new ResponseButtons
        //                {
        //                    type = "web_url",
        //                    title = "View",
        //                    url = "https://www.facebook.com/pg/OOP-Ezz-108722340761918"
        //                }
        //            },
        //            default_action = new PayloadElementDefautAction
        //            {
        //                type = "web_url",
        //                url = "https://www.facebook.com/pg/OOP-Ezz-108722340761918"
        //            }
        //        };
        //        listelement.Add(element);
        //    }

        //    List<ResponseButtons> lbt = new List<ResponseButtons>()
        //    {
        //        new ResponseButtons
        //        {
        //            title = "View More",
        //            type = "postback",
        //            payload = "payload view more"
        //        }
        //    };
        //    //listelement.RemoveAt(1);
        //    String json = fbTemplate.ListTemplate(botMessage.sender.id, listelement);
        //    _post(json);

        //}

        private void _rqQuestion(OOPEZZ_DBEntities db, BotMessageReceivedRequest botMessage)
        {
            String mess = botMessage.message.text.Remove(0, 6);

            mess = mess.Trim();
            mess = Ulti.replaceKeyword(db, mess);
            USER user      = db.USER.Where(x => x.TOKEN == botMessage.sender.id).FirstOrDefault();
            int  userpkseq = -1;

            if (user == null)
            {
                UserControl control = new UserControl();
                userpkseq = control.CreateUser(db, botMessage.sender.id);
            }
            else
            {
                userpkseq = user.PK_SEQ;
            }

            QUESTION ques = new QUESTION()
            {
                BEST_ANSWER_FK   = 0,
                QUESTION_TEXT    = mess,
                QUESTION_USER_FK = userpkseq,
                STATUS           = 0
            };

            db.QUESTION.Add(ques);
            db.SaveChanges();
            String json = fbTemplate.SimpleTextTemplate(botMessage.sender.id, "Oki đã ghi nhận nào có câu trả lời mình sẽ trả lời ngay");

            _post(json);
        }