public ActionResult SaveComment(int ASID, string CommentText, int?CommentId)
        {
            using (DBModel db = new DBModel())
            {
                var user     = User.Identity.Name;
                var userId   = db.RegisterUsers.FirstOrDefault(x => x.Email == user).AccountId;
                var username = db.RegisterUsers.FirstOrDefault(x => x.Email == user).FirstName;


                var Comment = new UserComment()
                {
                    AdminSectionId = ASID,
                    CommentText    = CommentText,
                    CreatedBy      = userId,
                    CreatedAt      = DateTime.Now,
                    ReplyCommentId = CommentId
                };

                //db.Comments.Add(Comment);
                //db.SaveChanges();
                db.UserComments.Add(Comment);
                db.SaveChanges();



                return(Json(new { success = true, comment = CommentText, user = username, created = DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #2
0
        public async Task <bool> SubmitComment(string ticketId, string comment)
        {
            var userComment = new UserComment
            {
                Body = new Body()
                {
                    Version = 1,
                    Type    = "doc",
                    Content = new List <Content>()
                    {
                        new Content()
                        {
                            ContentItems = new List <ContentItem>()
                            {
                                new ContentItem()
                                {
                                    Text = comment, Type = "text"
                                }
                            },
                            Type = "paragraph"
                        }
                    }
                }
            };

            return(await this.jiraService.TryAddCommentAsync(ticketId, userComment).ConfigureAwait(false));
        }
Пример #3
0
        public object Dislike()
        {
            var Comment_Id = Convert.ToInt32(HttpContext.Current.Request.Form["Comment_Id"]);
            var Token      = HttpContext.Current.Request.Form["Api_Token"];
            var user       = db.Users.Where(p => p.Api_Token == Token).FirstOrDefault();

            if (db.UserComments.Any(p => p.Comment.Id == Comment_Id && p.User.Id == user.Id))
            {
                return(new
                {
                    Message = 1
                });
            }

            var comment = db.Comments.Find(Comment_Id);

            if (comment.Status == true)
            {
                comment.Dislike++;
                var data = new UserComment();
                data.Comment = comment;
                data.User    = user;
                db.UserComments.Add(data);
                db.SaveChanges();
            }
            return(new { Message = 0 });
        }
Пример #4
0
        public string SaveComment(int parentId, string nick, string email, string web, string title, string text)
        {
            UserComment comment = new UserComment();

            comment.Web         = web;
            comment.Email       = Provider.User.IsAnonim() ? email : Provider.User.Email;
            comment.Nick        = Provider.User.IsAnonim() ? nick : Provider.User.Nick;
            comment.CommentText = text.Replace("\n", "\n<br/>");
            comment.ContentId   = Provider.Content.Id;
            comment.ParentId    = parentId;
            comment.Title       = title;
            comment.Visible     = !this.Moderated;

            // Nick boş ise kullanıcı nickini atayalım
            if (String.IsNullOrEmpty(comment.Nick))
            {
                comment.Nick = Provider.User.Nick; // anonim veya user nick
            }
            // IPyi atayalım
            comment.IP = Provider.Request.UserHostAddress;


            comment.Save();
            return(this.GetComment(comment, parentId));
        }
Пример #5
0
//        public static User GetUser(DataContext db, string username) {
//            var user =
//                db.Users.Local.FirstOrDefault(x => x.Name == username) ??
//                db.Users.FirstOrDefault(x => x.Name == username);
//            if (user == null)
//                db.Users.Add(user = new User {Name = username});
//            return user;
//        }

        public static void ProcessingComment(DataContext db, int postId, IEnumerable <CommentInfo> comments, string author)
        {
//            Dictionary<string, User> users = new Dictionary<string, User>();

//            foreach (var userName in comments.Select(x => x.UserName).Distinct()) {
//                users[userName] = GetUser(db, userName);
//            }

            db.Configuration.AutoDetectChangesEnabled = false;
            try {
                foreach (var comment in comments.OrderBy(x => x.Id))
                {
                    UserComment uc;
                    db.UserComments.Add(uc = new UserComment {
                        Id       = comment.Id,
                        UserName = comment.UserName,
//                        User = users[comment.UserName],
                        IsPostAuthor    = comment.UserName.Equals(author),
                        Rating          = comment.Rating,
                        PostId          = postId,
                        ParentCommentId = comment.ParentCommentId,
                        Level           = comment.Level,
                        Content         = comment.Content,
                        Created         = comment.DateTime,
                        Links           = comment.Links
                    });
                }
            }
            finally {
                db.Configuration.AutoDetectChangesEnabled = true;
            }
        }
Пример #6
0
        //
        public ActionResult Comment(int id, string commentText)
        {
            if (Session["email"] != null)
            {
                using (BitBookContext db = new BitBookContext())
                {
                    string userEmail = "";
                    userEmail = Session["email"].ToString();

                    var user = db.Users.FirstOrDefault(x => x.Email.Equals(userEmail));



                    UserComment aUserComment = new UserComment();
                    aUserComment.PostId   = id;
                    aUserComment.UserId   = user.Id;
                    aUserComment.PostText = commentText;

                    db.UserComments.Add(aUserComment);
                    db.SaveChanges();

                    return(RedirectToAction("Home", "Registration"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Registration"));
            }
        }
Пример #7
0
        public static CommentModel ConvertToCommentModel(UserComment userComment)
        {
            List <CommentRatingModel> commentRatings = new List <CommentRatingModel>();

            if (userComment.CommentRatings != null)
            {
                foreach (var rating in userComment.CommentRatings)
                {
                    var model = ConvertToCommentRatingModel(rating);
                    commentRatings.Add(model);
                }
            }

            CommentModel commentModel = new CommentModel
            {
                Id             = userComment.Id,
                Text           = userComment.Text,
                DataCreated    = userComment.DataCreated,
                OwnerId        = userComment.OwnerId,
                commentRatings = commentRatings,
                StoreItemId    = userComment.StoreItem_Id,
            };

            return(commentModel);
        }
Пример #8
0
        public async Task <Comment> AddComment(long userId, long bookId, Comment comment)
        {
            comment.AddedOn = DateTime.Now;

            _context.Comment.Add(comment);
            await _context.SaveChangesAsync();

            long commentId = comment.Id;

            var userComment = new UserComment {
                UserId = userId, CommentId = commentId, BookId = bookId
            };

            _context.UserComments.Add(userComment);
            await _context.SaveChangesAsync();

            var updatedBook = await _context.Book.FindAsync(bookId);

            updatedBook.UserComments.Add(userComment);
            await _context.SaveChangesAsync();

            var updatedUser = await _context.User.FindAsync(userId);

            updatedUser.UserComments.Add(userComment);
            await _context.SaveChangesAsync();

            return(comment);
        }
        public async Task <IActionResult> PutUserComment(int id, UserCommentDto userComment)
        {
            CommonResponse <UserCommentDto> response = new CommonResponse <UserCommentDto>();

            if (id != userComment.Id)
            {
                response.Error = new Error {
                    Status = 400, Message = "There was a mismatch with the provided id and the object."
                };
                return(BadRequest(response));
            }

            // Maps to model
            UserComment commentModel = _mapper.Map <UserComment>(userComment);

            _context.Entry(commentModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserCommentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #10
0
        public async Task <ActionResult <UserComment> > PostUserComment(UserComment userComment)
        {
            _context.UserComment.Add(userComment);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUserComment", new { id = userComment.UserCommentId }, userComment));
        }
Пример #11
0
        private static void AddComment(CafeController cafeController)
        {
            if (cafeController is null)
            {
                throw new ArgumentNullException(nameof(cafeController));
            }

            Console.WriteLine(resourceManager.GetString("ChooseCafe", culture));
            ShowCafes(cafeController);

            while (true)
            {
                var choice = Console.ReadLine();
                var cafe   = cafeController.Cafes.FirstOrDefault(c => c.Name == choice);
                if (cafe != null)
                {
                    Console.Write(resourceManager.GetString("EnterRating", culture));
                    var rating = EnterRating();

                    Console.Write(resourceManager.GetString("EnterComment", culture));
                    var comment = Console.ReadLine();

                    var userComment = new UserComment(cafeController.CurrentUser, cafe.Name, rating, comment);
                    cafeController.AddComment(userComment);
                    break;
                }
                else
                {
                    ShowError(resourceManager.GetString("ErrorDoesNotExistCafe", culture));
                }
            }
        }
Пример #12
0
        public bool InsertUserComment(UserComment userComment)
        {
            DatabaseProviderFactory factory = new DatabaseProviderFactory();
            Database db = factory.CreateDefault();

            try
            {
                System.Data.Common.DbCommand dbCommandWrapper = db.GetStoredProcCommand(Utility.Constant.SPInsertUserComments);

                db.AddInParameter(dbCommandWrapper, "@name", DbType.String, userComment.name == null ? DBNull.Value : (object)userComment.name);
                db.AddInParameter(dbCommandWrapper, "@lat", DbType.Decimal, userComment.lat);
                db.AddInParameter(dbCommandWrapper, "@lng", DbType.Decimal, userComment.lng);
                db.AddInParameter(dbCommandWrapper, "@comment", DbType.String, userComment.comment == null ? DBNull.Value : (object)userComment.comment);
                db.ExecuteNonQuery(dbCommandWrapper);
                return(true);
            }
            catch
            {
                throw;
            }
            finally
            {
                db = null;
            }
        }
Пример #13
0
        // GET: ManageUserComments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserComment userComment = db.UserComments.Find(id);

            if (userComment == null)
            {
                return(HttpNotFound());
            }

            // BEGIN: Tạo ra dropdownlist cho trường Status
            List <SelectListItem> statusList = new List <SelectListItem>();

            statusList.Add(new SelectListItem {
                Text = "ACTIVE", Value = "ACTIVE"
            });
            statusList.Add(new SelectListItem {
                Text = "DEACTIVE", Value = "DEACTIVE"
            });

            ViewBag.Status = new SelectList(statusList, "Value", "Text");
            return(View(userComment));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Content,ProductId,IdentityUserId")] UserComment userComment)
        {
            if (id != userComment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userComment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserCommentExists(userComment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Redirect("/home"));
            }
            ViewData["IdentityUserId"] = new SelectList(_context.Users, "Id", "Id", userComment.IdentityUserId);
            ViewData["ProductId"]      = new SelectList(_context.Products, "Id", "Id", userComment.ProductId);
            return(View(userComment));
        }
Пример #15
0
        public async Task <ActionResult <UserComment> > PostComment(int postId, UserComment commentDto)
        {
            if (!await PostExists(postId))
            {
                return(NotFound());
            }

            var comment = _context.UserComments
                          .Find(commentDto.Id);

            if (comment == null)
            {
                //map to new comment entity etc.
                comment = commentDto;
                _context.UserComments.Add(comment);
            }
            else
            {
                //override only editable values etc.
                comment = commentDto;
                _context.UserComments.Update(comment);
            }

            await _context.SaveChangesAsync();

            await BroadcastPostUpdated(postId);

            return(Ok());
        }
Пример #16
0
        public async Task <ActionResult <Comment> > EditComment(long commentId, CommentForUpdateDto commentForUpdateDto)
        {
            UserComment userComment = await _context.UserComments.FirstOrDefaultAsync(uc => uc.CommentId == commentId);

            if (userComment == null)
            {
                return(BadRequest("No comment with the given Id was found"));
            }

            if (userComment.UserId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            if (commentId != commentForUpdateDto.Id)
            {
                return(BadRequest("A mismatch between the Id of the comment to update and the Id of the updated comment was found"));
            }

            if (!CommentExists(commentId))
            {
                return(NotFound());
            }

            var comment = await _context.Comments.FirstOrDefaultAsync(c => c.Id == commentId);

            comment.CommentText = commentForUpdateDto.CommentText;

            await _context.SaveChangesAsync();

            return(Ok());
        }
Пример #17
0
 public Comment(PlayStationClient client, UserComment comment, Story story)
 {
     this.Client      = client;
     this.Information = comment;
     this._story      = story;
     this._submitter  = new Lazy <User>(() => new User(Client, this.Information.OnlineId));
 }
Пример #18
0
        public async Task <IActionResult> PostUserComment(string content, int userPageID)
        {
            // Redirects if content is null
            if (content == null)
            {
                return(Redirect("/"));
            }

            // Creates and posts comment
            UserComment comment = new UserComment()
            {
                Content    = content,
                DatePosted = DateTime.Now,
                UserID     = Tools.GetUserID(User),
                UserPageID = userPageID,
            };
            Result result = await _repository.PostUserCommentAsync(comment);

            // Saves changes and redirects if successful, otherwise returns 403
            if (result.Success)
            {
                await _repository.SaveChangesAsync();

                return(Redirect("/User?id=" + userPageID));
            }
            return(StatusCode(result.Code));
        }
 public int SaveUserComment(UserComment comment)
 {
     if (comment.UserCommentID == 0)
     {
         db.UserComments.Add(comment);
         db.SaveChanges();
     }
     else
     {
         try
         {
             db.Entry(comment).State = EntityState.Modified;
             db.SaveChanges();
         }
         catch
         {
             return(0);
         }
         //try
         //{
         //    db.Entry(comment).State = EntityState.Modified;
         //    db.SaveChanges();
         //}
         //catch (OptimisticConcurrencyException ex)
         //{
         //    RDL.Debug.LogError(ex);
         //}
     }
     return(comment.UserCommentID);
 }
Пример #20
0
        public List <UserComment> GetCommentByPostCode(string pPostCode, SqlConnection connection)
        {
            List <UserComment> commentList = new List <UserComment>();


            string vComTxt = @"select CommentsCode,C.UserCode,C.ActionDate,C.ActionType,Comments,PostCode,U.UserFullName
            from UserComments C 
			JOIN UserInfo U ON C.usercode = U.UserCode
			where PostCode = '"             + pPostCode + "' AND C.ActionType <> 'DELETE' ORDER BY C.ActionDate DESC";

            SqlCommand    objDbCommand = new SqlCommand(vComTxt, connection);
            SqlDataReader dr;

            dr = objDbCommand.ExecuteReader();
            while (dr.Read())
            {
                UserComment obj = new UserComment();
                obj.CommentsCode = dr["CommentsCode"].ToString();
                obj.UserCode     = dr["UserCode"].ToString();
                obj.ActionDate   = dr.GetDateTime(dr.GetOrdinal("ActionDate"));
                obj.ActionType   = dr["ActionType"].ToString();
                obj.Comments     = dr["Comments"].ToString();
                obj.PostCode     = dr["PostCode"].ToString();
                obj.UserFullName = dr["UserFullname"].ToString();
                obj.VotetypeList = GetVotetypeByCommentsCode(obj.CommentsCode, connection);
                commentList.Add(obj);
            }
            dr.Close();
            return(commentList);
        }
Пример #21
0
        public void ShouldBeErrorIfNoKeyDelete()
        {
            string encryptionKey = null;
            DBResult <UserProfile> profileDBResult = new DBResult <UserProfile>
            {
                Payload = new UserProfile()
                {
                    EncryptionKey = encryptionKey
                }
            };

            Mock <IUserProfileDelegate> profileDelegateMock = new Mock <IUserProfileDelegate>();

            profileDelegateMock.Setup(s => s.GetUserProfile(hdid)).Returns(profileDBResult);

            UserComment userComment = new UserComment()
            {
                UserProfileId   = hdid,
                ParentEntryId   = parentEntryId,
                Text            = "Deleted Comment",
                EntryTypeCode   = Database.Constants.CommentEntryType.Medication,
                CreatedDateTime = new DateTime(2020, 1, 1)
            };

            ICommentService service = new CommentService(
                new Mock <ILogger <CommentService> >().Object,
                new Mock <ICommentDelegate>().Object,
                profileDelegateMock.Object,
                new Mock <ICryptoDelegate>().Object
                );

            RequestResult <UserComment> actualResult = service.Delete(userComment);

            Assert.Equal(ResultType.Error, actualResult.ResultStatus);
        }
Пример #22
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Comment,DocumentID,UserID,Vote")] UserComment userComment)
        {
            if (id != userComment.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userComment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserCommentExists(userComment.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["DocumentID"] = new SelectList(_context.Documents, "ID", "ID", userComment.DocumentID);
            ViewData["UserID"]     = new SelectList(_context.Users, "ID", "ID", userComment.UserID);
            return(View(userComment));
        }
Пример #23
0
        public async Task <IActionResult> PutUserComment(int id, UserComment userComment)
        {
            if (id != userComment.UserCommentId)
            {
                return(BadRequest());
            }

            _context.Entry(userComment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserCommentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #24
0
        public IActionResult Create(UserComment userComment, int id)
        {
            //if (User.Identity.IsAuthenticated)
            //{
            //    var user = User.Identity.Name;
            //    var model = _userManager.Users.FirstOrDefault(x => x.UserName == user);
            //var payment = _context.Payments.Find(id);
            ////var product = _context.Products.Find(id);

            var comment = _context.UserComments.FirstOrDefault(x => x.Id == id);

            ////var add = new UserComment
            ////{
            ////    UserId = model.Id,
            ////    //PaymentId = payment.Id,
            ////    ProductId = product.Id,
            ////    UserName = model.UserName,
            ////    Email = model.Email,
            ////    Comment = comment.Comment,
            ////    Date = DateTime.Now



            ////};
            _context.UserComments.Add(userComment);
            ////TempData["create"] = "Yorum" + " " + comment.Comment + "" + " eklendi.";
            _context.SaveChanges();
            return(View(userComment));
        }
Пример #25
0
        //void UpdateModel(string comment, int? id)
        //{


        //}
        public void DeleteCommentByCommentId(int?id)
        {
            UserComment c = db.UserComments.Find(id);

            db.UserComments.Remove(c);
            db.SaveChanges();
        }
Пример #26
0
        /// <summary>
        /// 用户写评论
        /// 2019/5/11
        /// </summary>
        /// <returns></returns>
        public async Task <OutputUserCommentDto> CreateComment([FromBody] UserCommentDto userCommentDto)
        {
            string articleId = userCommentDto.ArticleId;

            //查询评论区
            var commentArea = await _commentRepository
                              .GetCommentAreaByIdAsync(articleId);

            //如果评论区不存在,直接返回false
            if (commentArea == null)
            {
                _logger.LogError("评论区不存在,用户写评论失败");
                return(null);
            }

            //如果评论区存在,写入评论(1级评论)
            //AutoMapper映射
            UserComment userComment = userCommentDto.MapTo <UserComment>();

            //如果留言成功,会返回留言内容
            UserComment successCommentContent = await _commentRepository.AddCommentToAreaAsync(userComment, articleId);

            //向客户端返回留言内容
            return(successCommentContent.MapTo <OutputUserCommentDto>());
        }
Пример #27
0
        /// <inheritdoc />
        public RequestResult <IEnumerable <UserComment> > GetEntryComments(string hdId, string parentEntryId)
        {
            UserProfile profile = this.profileDelegate.GetUserProfile(hdId).Payload;
            string?     key     = profile.EncryptionKey;

            // Check that the key has been set
            if (key == null)
            {
                this.logger.LogError($"User does not have a key: ${hdId}");
                return(new RequestResult <IEnumerable <UserComment> >()
                {
                    ResultStatus = ResultType.Error,
                    ResultError = new RequestResultError()
                    {
                        ResultMessage = "Profile Key not set", ErrorCode = ErrorTranslator.InternalError(ErrorType.InvalidState)
                    },
                });
            }

            DBResult <IEnumerable <Comment> >          dbComments = this.commentDelegate.GetByParentEntry(hdId, parentEntryId);
            RequestResult <IEnumerable <UserComment> > result     = new RequestResult <IEnumerable <UserComment> >()
            {
                ResourcePayload  = UserComment.CreateListFromDbModel(dbComments.Payload, this.cryptoDelegate, key),
                TotalResultCount = dbComments.Payload.Count(),
                PageIndex        = 0,
                PageSize         = dbComments.Payload.Count(),
                ResultStatus     = dbComments.Status == DBStatusCode.Read ? ResultType.Success : ResultType.Error,
                ResultError      = dbComments.Status != DBStatusCode.Read ? new RequestResultError()
                {
                    ResultMessage = dbComments.Message, ErrorCode = ErrorTranslator.ServiceError(ErrorType.CommunicationInternal, ServiceType.Database)
                } : null,
            };

            return(result);
        }
Пример #28
0
        /// <inheritdoc />
        public RequestResult <UserComment> Add(UserComment userComment)
        {
            UserProfile profile = this.profileDelegate.GetUserProfile(userComment.UserProfileId).Payload;
            string?     key     = profile.EncryptionKey;

            if (key == null)
            {
                this.logger.LogError($"User does not have a key: ${userComment.UserProfileId}");
                return(new RequestResult <UserComment>()
                {
                    ResultStatus = ResultType.Error,
                    ResultError = new RequestResultError()
                    {
                        ResultMessage = "Profile Key not set", ErrorCode = ErrorTranslator.InternalError(ErrorType.InvalidState)
                    },
                });
            }

            Comment comment = userComment.ToDbModel(this.cryptoDelegate, key);

            DBResult <Comment>          dbComment = this.commentDelegate.Add(comment);
            RequestResult <UserComment> result    = new RequestResult <UserComment>()
            {
                ResourcePayload = UserComment.CreateFromDbModel(dbComment.Payload, this.cryptoDelegate, key),
                ResultStatus    = dbComment.Status == DBStatusCode.Created ? ResultType.Success : ResultType.Error,
                ResultError     = new RequestResultError()
                {
                    ResultMessage = dbComment.Message, ErrorCode = ErrorTranslator.ServiceError(ErrorType.CommunicationInternal, ServiceType.Database)
                },
            };

            return(result);
        }
Пример #29
0
        private UserComment ReturnStampImage(UserComment rawData)
        {
            UserComment UserCommentTemp = new UserComment();

            UserCommentTemp = rawData;

            int urlPointStart = UserCommentTemp.text.IndexOf("src=\"") + 5;
            int urlPointEnd   = UserCommentTemp.text.IndexOf(".png\"") + 4;

            UserCommentTemp.StampUrl = UserCommentTemp.text.Substring(urlPointStart, urlPointEnd - urlPointStart);

            try
            {
                int urlFIlenameStart = UserCommentTemp.StampUrl.IndexOf("full") + 5;
                int urlFIlenameEnd   = UserCommentTemp.StampUrl.IndexOf(".png");

                UserCommentTemp.StampFileName = UserCommentTemp.StampUrl.Substring(urlFIlenameStart, urlFIlenameEnd - urlFIlenameStart) + ".png";
            }
            catch
            {
                UserCommentTemp.StampFileName = string.Empty;
            }

            try
            {
                FileDownloader(UserCommentTemp.StampUrl, UserCommentTemp.StampFileName);
            }
            catch (Exception ex)
            {
                GrandcypherClient.Current.PostMan("스탬프 이미지를 받아오는데 문제가 발생하였습니다.");
                Debug.WriteLine(ex);
            }

            return(UserCommentTemp);
        }
Пример #30
0
        public string Comment(int restId, string comment)
        {
            var    userModel = _dalUser.GetModel(User.Identity.GetUserId(), User.Identity.GetUserName());
            string userName  = userModel.FirstName + userModel.LastName;

            // if user haven't eaten in this restuant, then he/she cannot make a comment
            if (!_dalUserRes.IsHaveUserRecord(userName))
            {
                return("You haven't eaten in this restaurant yet. So you can't comment.");
            }
            var comModel = new UserComment();

            comModel.UserName     = userName;
            comModel.RestaurantID = restId;
            comModel.Comment      = comment;
            //return comments results
            if (_dalComment.Add(comModel) > 0)
            {
                return("Comment on success.");
            }
            else
            {
                return("Comment failed. Please try again later.");
            }
        }
Пример #31
0
        public ActionResult AddUserComment(AddUserCommentViewModel vm)
        {
            var ops= new BlogPostOperations();
            var userComment = new UserComment();
            userComment.UserCommentContent = vm.UserCommentContent;
            userComment.UserCommentDate = DateTime.Parse(vm.UserCommentDate);
            userComment.UserCommentUserName = vm.UserCommentUserName;

            ops.AddNewUserComment(userComment, vm.PostID);

            return RedirectToAction("ListSinglePost", new {id= vm.PostID});
        }
Пример #32
0
        private UserComment ReturnStampImage(UserComment rawData)
        {
            UserComment UserCommentTemp = new UserComment();
            UserCommentTemp = rawData;

            int urlPointStart = UserCommentTemp.text.IndexOf("src=\"") + 5;
            int urlPointEnd = UserCommentTemp.text.IndexOf(".png\"") + 4;
            UserCommentTemp.StampUrl = UserCommentTemp.text.Substring(urlPointStart, urlPointEnd - urlPointStart);

            try
            {
                int urlFIlenameStart = UserCommentTemp.StampUrl.IndexOf("full") + 5;
                int urlFIlenameEnd = UserCommentTemp.StampUrl.IndexOf(".png");

                UserCommentTemp.StampFileName = UserCommentTemp.StampUrl.Substring(urlFIlenameStart, urlFIlenameEnd - urlFIlenameStart) + ".png";
            }
            catch
            {
                UserCommentTemp.StampFileName = string.Empty;
            }

            try
            {
                FileDownloader(UserCommentTemp.StampUrl, UserCommentTemp.StampFileName);
            }
            catch (Exception ex)
            {
                GrandcypherClient.Current.PostMan("스탬프 이미지를 받아오는데 문제가 발생하였습니다.");
                Debug.WriteLine(ex);
            }

            return UserCommentTemp;
        }
Пример #33
0
        /// <summary>
        /// Helper method
        /// </summary>
        /// <param name="us"></param>
        /// <param name="settings"></param>
        /// <param name="comment"></param>
        private void sendStreamEmailAsync(UserStream us, UserSettings settings, UserComment comment)
        {
            string emailBody = settings.UserName + " commented.\n\n";
            emailBody += "\"" + Affine.Utils.Web.WebUtils.FromWebSafeString( comment.Text ) + "\"\n\n";
            emailBody += "To see the comment thread, follow the link below:\n";

            string ts = Convert.ToString(DateTime.Now.Ticks);
            if (us is Recipe)
            {
                emailBody += "http://" + HttpContext.Current.Request.Url.Host.Replace("www.","") + System.Web.VirtualPathUtility.ToAbsolute("~/Search.aspx") + "?r="+us.Id + "&ts="+ts;
            }
            else
            {
                emailBody += "http://" + HttpContext.Current.Request.Url.Host.Replace("www.", "") + "/" + us.UserSetting.UserName + "?s=" + us.Id + "&ts=" + ts;
            }
            string subject = settings.UserName + " commented on your post...";

            Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();
            // Send an email to the owner of the post
            if (us.UserSetting.Id != settings.Id)
            {
                gmail.Send(us.UserSetting.UserEmail, subject, emailBody);
            }

            aqufitEntities entities = new aqufitEntities();
            IQueryable<UserComment> comments = entities.UserComment.Include("UserSetting").Where(uc => uc.UserStream.Id == us.Id);
            string[] emails = comments.Select(uc => uc.UserSetting.UserEmail).Distinct().ToArray();
            foreach (string email in emails)
            {
                if (email != us.UserSetting.UserEmail && email != settings.UserEmail)
                {
                    gmail.Send(email, settings.UserName + " commented.", emailBody);
                }
            }
        }
Пример #34
0
        public void AddUserComment(UserComment newUserComment, int postID)
        {
            var p = new DynamicParameters();
            p.Add("PostID", postID);
            p.Add("UserCommentUserName", newUserComment.UserCommentUserName);
            p.Add("UserCommentContent", newUserComment.UserCommentContent);
            p.Add("UserCommentDate", newUserComment.UserCommentDate);
            p.Add("UserCommentID", dbType: DbType.Int32, direction:ParameterDirection.Output);

            _cn.Execute("AddNewUserComment", p, commandType: CommandType.StoredProcedure);
            p.Get<int>("UserCommentID");
        }
Пример #35
0
 public void AddNewUserComment(UserComment newUserComment, int postID)
 {
     _repo.AddUserComment(newUserComment, postID);
 }