Exemplo n.º 1
0
        public string Replay(string hashcode)
        {
            bool checkGio    = false;
            int  idQuestion  = int.Parse(hashcode);
            var  currentPost = _postService.GetById(int.Parse(hashcode));
            var  userId      = User.Identity.GetUserId();
            //Kiem tra xem con thoi gian tra loi hay ko
            var sendQues = _haveSendQuesService.GetAll().Where(x => x.QuesID == idQuestion && x.UserID == userId).ToList().FirstOrDefault();

            if (sendQues != null)
            {
                var timePost    = sendQues.CreatedDate.Value.AddMinutes(TimeSetting.LimitMinuteForPost()).Ticks;
                var timeCurrent = DateTime.Now.Ticks;
                if (timePost < timeCurrent)
                {
                    checkGio = true;
                }
            }
            //
            //  currentPost.Post_Status = 1;
            // _postService.Update(currentPost);
            //_postService.Save();
            // DateTime
            return(checkGio ? "Vui lòng trả lời" : "Link hết hạn");
        }
Exemplo n.º 2
0
        public async Task <string> replayDirectly(string idques, string ketqua, string idmessenger)
        {
            //
            ChatfuelJson result   = new ChatfuelJson();
            MessJson     messPron = new MessJson();
            //
            bool checkGio    = false;
            int  idQuestion  = int.Parse(idques);
            var  currentPost = _postService.GetById(idQuestion);
            var  userId      = _service.listUserID().Where(x => x.Id_Messenger == idmessenger).FirstOrDefault().Id;
            //Kiem tra xem con thoi gian tra loi hay ko
            var sendQues = _haveSendQuesService.GetAll().Where(x => x.QuesID == idQuestion && x.UserID == userId).ToList().FirstOrDefault();

            if (sendQues != null)
            {
                int tempMinute  = TimeSetting.LimitMinuteForPost();
                var timePost    = sendQues.CreatedDate.Value.AddMinutes(tempMinute).Ticks;
                var timeCurrent = DateTime.Now.AddMinutes(-5).Ticks;
                if (timePost < timeCurrent)
                {
                    checkGio = true;
                }
                else
                {
                    currentPost.Post_Status = 10;
                    Comment comment = new Comment();
                    comment.Corrected   = false;
                    comment.Content     = ketqua;
                    comment.Id_User     = userId;
                    comment.Id_Post     = idQuestion;
                    comment.DateComment = DateTime.Now.Ticks.ToString();
                    _commentOfPost.Add(comment);
                    _commentOfPost.Save();
                    _postService.Update(currentPost);
                    _postService.Save();
                    messPron.text = "Cám ơn bạn đã phản hồi";
                    result.messages.Add(messPron);
                    await notifyForUserAboutQues(idQuestion);

                    return(JsonConvert.SerializeObject(result));
                }
            }
            //
            //  currentPost.Post_Status = 1;
            // _postService.Update(currentPost);
            //_postService.Save();
            // DateTime
            messPron.text = "Hết hạn trả lời, cảm ơn bạn đã quan tâm";
            result.messages.Add(messPron);
            return(JsonConvert.SerializeObject(result));
        }
Exemplo n.º 3
0
        //Get tat ca cac post co thoi gian tao it hon hien tai 5'
        protected List <Post> getPost()
        {
            List <Post> listResult = new List <Post>();
            List <Post> listPost   = _postService.GetAll().Where(post => post.Post_Status == 0 && post.Option == 1).ToList();

            foreach (var post in listPost)
            {
                var timePost    = post.CreatedDate.Value.AddMinutes(TimeSetting.LimitMinuteForPost()).Ticks;
                var timeCurrent = DateTime.Now.Ticks;
                if (timePost < timeCurrent)
                {
                    listResult.Add(post);
                }
            }
            return(listResult);
        }
Exemplo n.º 4
0
        public string busyNotReplay(string idques, string idmessenger)
        {
            ChatfuelJson result   = new ChatfuelJson();
            MessJson     messPron = new MessJson();

            //
            bool isHetGio    = false;
            int  idQuestion  = int.Parse(idques);
            var  currentPost = _postService.GetById(idQuestion);
            var  userId      = _service.listUserID().Where(x => x.Id_Messenger == idmessenger).FirstOrDefault().Id;
            //Kiem tra xem con thoi gian tra loi hay ko
            var sendQues = _haveSendQuesService.GetAll().Where(x => x.QuesID == idQuestion && x.UserID == userId).ToList().FirstOrDefault();

            if (sendQues != null && currentPost.Post_Status != 10)
            {
                var timePost    = sendQues.CreatedDate.Value.AddMinutes(TimeSetting.LimitMinuteForPost()).Ticks;
                var timeCurrent = DateTime.Now.Ticks;
                if (timePost < timeCurrent)
                {
                    isHetGio = true;
                }
            }
            else
            {
                messPron.text = "Câu hỏi không tồn tại hoặc đã trả lời";
                result.messages.Add(messPron);
                return(JsonConvert.SerializeObject(result));
            }
            if (!isHetGio)
            {
                messPron.text           = "Bạn đã bỏ qua câu hỏi số :" + idques;
                currentPost.CreatedDate = DateTime.Now.AddMinutes(-TimeSetting.LimitMinuteForPost());
                _postService.Update(currentPost);
                _postService.Save();
                result.messages.Add(messPron);
                return(JsonConvert.SerializeObject(result));
            }
            messPron.text = "Hết giờ hoặc đã trả lời";
            result.messages.Add(messPron);
            return(JsonConvert.SerializeObject(result));
        }