public bool CreateComment(string id, string comment)
        {
            int rightId;

            if (Int32.TryParse(id, out rightId) &&
                !String.IsNullOrEmpty(comment))
            {
                if (_fileDao.GetFileById(rightId) != null)
                {
                    _commentDao.CreateComment(rightId, comment);

                    return(true);
                }
                else
                {
                    Console.WriteLine("Can't find file");
                    return(false);
                }
            }
            else
            {
                Console.WriteLine("Incorrect ID (not number) or incorrect comment (empty)");
                return(false);
            }
        }
Пример #2
0
        public async Task <ActionResult <object> > CreateComment(Comment comment)
        {
            bool user_state = false;
            int  comment_id = -1;

            if (Check.CheckUserState(Request, HttpContext) > 0)
            {
                user_state = true;
                long user_id = long.Parse(Request.Cookies["user"]);
                comment.user_id = user_id;
                comment.time    = DateTime.Now;
                comment_id      = dao.CreateComment(comment);
            }
            Dictionary <string, object> result = new Dictionary <string, object>();

            result.Add("user_state", user_state);
            result.Add("comment_id", comment_id);
            return(JsonConvert.SerializeObject(result));
        }