Ejemplo n.º 1
0
        public async Task WriteCommentAsync(ReviewComment reviewComment, Message message)
        {
            if (reviewComment.Id != 0)
            {
                if (reviewComment.LogFilePath != null)
                {
                    await using FileStream fs   = new FileStream(reviewComment.LogFilePath, FileMode.Append, FileAccess.Write);
                    await using StreamWriter sw = new StreamWriter(fs);
                    await sw.WriteLineAsync(JsonSerializer.Serialize(message));

                    return;
                }
            }

            {
                var path = Environment.CurrentDirectory + @"\CommentsLog\" + $"{new Guid()}.txt";
                reviewComment.LogFilePath = path;
                await _context.ReviewComments.AddAsync(reviewComment);

                await _context.SaveChangesAsync();

                await using FileStream fs   = new FileStream(path, FileMode.Append, FileAccess.Write);
                await using StreamWriter sw = new StreamWriter(fs);
                await sw.WriteLineAsync(JsonSerializer.Serialize(message));
            }
        }
Ejemplo n.º 2
0
        public void NextComment()
        {
            int nextIndex = loadedContainer.comments.IndexOf(currentComment) + 1;

            if (nextIndex >= loadedContainer.comments.Count)
            {
                return;
            }
            else
            {
                Timeline
                .instance
                .DeselectAllTargets();

                currentComment = loadedContainer.comments[nextIndex];

                Cue firstCue = currentComment.selectedCues.FirstOrDefault();
                Cue lastCue  = currentComment.selectedCues.LastOrDefault();

                foreach (Target target in SelectTargets(firstCue.tick, lastCue.tick))
                {
                    target.Select();
                }

                Timeline
                .instance
                .AnimateSetTime(new QNT_Timestamp((ulong)firstCue.tick));
            }
        }
Ejemplo n.º 3
0
        public IActionResult Edit(ReviewCommentEditViewModel viewModel)
        {
            ReviewComment comment = reviewCommentService.GetByID(viewModel.ReviewComment.ID);

            comment.Body = viewModel.ReviewComment.Body;

            reviewCommentService.Update(comment);

            return(RedirectToAction("Details", comment));
        }
Ejemplo n.º 4
0
        public void PreviousComment()
        {
            int nextIndex = loadedContainer.comments.IndexOf(currentComment) - 1;

            if (nextIndex < 0)
            {
                return;
            }
            else
            {
                currentComment = loadedContainer.comments[nextIndex];
            }
        }
Ejemplo n.º 5
0
 public ReviewCommentVM CreateReviewCommentVM(ReviewComment item)
 {
     return(new ReviewCommentVM
     {
         id = item.Id,
         comment = item.Comment,
         created = item.Created,
         oId = item.OrderId,
         rId = item.DesignReviewId,
         uId = item.UserId,
         uName = item.Username,
     });
 }
Ejemplo n.º 6
0
        public IActionResult Delete(ReviewCommentDeleteViewModel viewModel)
        {
            ReviewComment comment = reviewCommentService.GetByID(viewModel.ReviewComment.ID);

            if (comment == null)
            {
                return(NotFound());
            }

            reviewCommentService.Delete(comment.ID);

            return(RedirectToAction("Index"));
        }
        public IHttpActionResult AddReviewComment(AddCommentParameters commentParams)
        {
            if (ModelState.IsValid)
            {
                var productreview = _repository.Reviews.FirstOrDefault(r => r.ReviewId == commentParams.Id);

                if (productreview == null)
                {
                    return(NotFound());
                }

                try
                {
                    var reviewComment = new ReviewComment
                    {
                        AuthorId        = UserHelper.CustomerSession.CustomerId,
                        AuthorLocation  = commentParams.AuthorLocation,
                        AuthorName      = commentParams.AuthorName,
                        Comment         = commentParams.Comment,
                        ReviewId        = productreview.ReviewId,
                        ReviewCommentId = Guid.NewGuid().ToString(),
                        Status          = (int)ReviewStatus.Pending
                    };

                    productreview.ReviewComments.Add(reviewComment);

                    _repository.Update(productreview);
                    _repository.UnitOfWork.Commit();

                    return(Ok(new MReviewComment
                    {
                        Comment = reviewComment.Comment,
                        CreatedDateTime = reviewComment.Created,
                        Id = reviewComment.ReviewCommentId,
                        Reviewer = new MReviewer
                        {
                            Address = reviewComment.AuthorLocation,
                            Id = reviewComment.AuthorId,
                            NickName = reviewComment.AuthorName
                        }
                    }));
                }
                catch
                {
                    return(BadRequest("Error while saving data to database.".Localize()));
                }
            }
            return(BadRequest());
        }
 protected override void LoadInnerItem()
 {
     if (IsReview)
     {
         var item =
             (Repository as IReviewRepository).Reviews.Where(x => x.ReviewId == OriginalItem.ReviewBaseId).Expand(x => x.ReviewFieldValues).SingleOrDefault();
         OnUIThread(() => InnerItem = new Review(item));
     }
     else
     {
         var item =
             (Repository as IReviewRepository).ReviewComments.Where(x => x.ReviewCommentId == OriginalItem.ReviewBaseId).Expand(x => x.Review).SingleOrDefault();
         OnUIThread(() => InnerItem = new ReviewComment(item));
     }
 }
Ejemplo n.º 9
0
        public IActionResult Create(ReviewCommentCreateViewModel viewModel)
        {
            ReviewComment comment = new ReviewComment()
            {
                ID          = viewModel.ReviewComment.ID,
                Body        = viewModel.ReviewComment.Body,
                DateCreated = DateTime.Now,
                CreatedByID = userManager.GetUserAsync(HttpContext.User).Result.Id,
                CreatedBy   = userManager.GetUserAsync(HttpContext.User).Result,
                Review      = viewModel.ReviewComment.Review
            };

            reviewCommentService.Insert(comment);

            return(View(viewModel));
        }
Ejemplo n.º 10
0
        public IHttpActionResult AddComment(Guid rid, [FromBody] ReviewCommentBM model)
        {
            DesignReview dbReview = UOW.DesignReviews.GetOwnById(rid, UserRecord.Id);

            if (dbReview == null)
            {
                return(new SkyApiNotFound(Request));
            }
            ReviewDocument dbOption = UOW.ReviewDocuments.GetById(model.oid);

            if (dbOption == null)
            {
                return(new SkyApiNotFound(Request));
            }

            if (dbReview.AcceptedDate != null)
            {
                ModelState.AddModelError("", "Review has been accepted and further changes are not allowed.");
                return(new SkyApiBadRequest(Request, new SkyModelStateError(ModelState)));
            }

            ReviewComment reviewComment = new ReviewComment
            {
                Comment = model.comment,
                // TODO: looks like a typo (OrderId should be OptionId)
                OrderId        = dbOption.Id,
                DesignReviewId = rid,
                UserId         = new Guid(UserRecord.Id),
                Username       = UserRecord.UserName
            };

            dbReview.ReviewComments.Add(reviewComment);

            UOW.Commit();

            IDictionary <string, string> formData = new Dictionary <string, string>();

            formData.Add("User", UserRecord.FullName);
            formData.Add("Project", dbReview.Project.Name);
            formData.Add("Review", dbReview.Title);
            formData.Add("Option", dbOption.Title);
            formData.Add("Commment", model.comment);
            MailService.SendNotification(formData, "Skyberry Notification: New Comment");

            return(new SkyApiPayload <ReviewCommentVM>(Request, ModelFactory.CreateReviewCommentVM(reviewComment)));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> AddComment([FromRoute] int reviewId
                                                     , [FromBody] ReviewComment reviewComment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ReviewAC reviewAC = new ReviewAC();

            reviewAC.Comment = reviewComment;
            await _unitOfWork.Review.AddReviewComment(reviewId, reviewAC);

            await _unitOfWork.Save();

            return(Ok(reviewComment));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates a review comment using selected notes and text fields.
        /// </summary>
        public void CreateComment()
        {
            var selectedCues = new List <Cue>();

            foreach (Target target in Timeline.instance.selectedNotes)
            {
                selectedCues.Add(target.ToCue());
            }

            var comment = new ReviewComment(selectedCues.ToArray(),
                                            descriptionField.text,
                                            (CommentType)int.Parse(commentTypeGroup.ActiveToggles().FirstOrDefault().name));

            loadedContainer.comments.Add(comment);

            string targetPlural = selectedCues.Count == 1 ? "target" : "targets";

            NotificationShower.Queue($"Added comment for {selectedCues.Count} {targetPlural}", NRNotifType.Success);
        }
Ejemplo n.º 13
0
        public Expression <Func <Entities.Review, bool> > GetFilter()
        {
            Expression <Func <Entities.Review, bool> > filter = x => true;

            if (this.Id.HasValue)
            {
                filter = filter.And(x => x.Id == Id);
            }

            if (!string.IsNullOrEmpty(ReviewComment))
            {
                filter = filter.And(x => x.ReviewComment.Trim().ToLower().Contains(ReviewComment.Trim().ToLower()));
            }

            if (this.Stars.HasValue)
            {
                filter = filter.And(x => x.Stars == Stars);
            }

            return(filter);
        }
Ejemplo n.º 14
0
        public IActionResult Edit(int id)
        {
            if (id == 0)
            {
                return(NotFound());
            }

            ReviewComment comment = reviewCommentService.GetByID(id);

            if (comment == null)
            {
                return(NotFound());
            }

            ReviewCommentEditViewModel viewModel = new ReviewCommentEditViewModel()
            {
                ReviewComment = comment,
                Review        = comment.Review
            };

            return(View(viewModel));
        }
Ejemplo n.º 15
0
        public async Task <ReviewComment> UpsertAsync(ReviewCommentCreate reviewCommentCreate, int applicationUserId)
        {
            using (var dataTable = new DataTable())
            {
                dataTable.Columns.Add("ReviewCommentId", typeof(int));
                dataTable.Columns.Add("ParentReviewCommentId", typeof(int));
                dataTable.Columns.Add("ReviewId", typeof(int));
                dataTable.Columns.Add("Content", typeof(string));

                dataTable.Rows.Add(
                    reviewCommentCreate.ReviewCommentId,
                    reviewCommentCreate.ParentReviewCommentId,
                    reviewCommentCreate.ReviewId,
                    reviewCommentCreate.Content);

                int?newReviewCommentId;

                using (var connection = new SqlConnection(_config.GetConnectionString("DefaultConnection")))
                {
                    await connection.OpenAsync();

                    newReviewCommentId = await connection.ExecuteScalarAsync <int?>(
                        "ReviewComment_Upsert",
                        new
                    {
                        ReviewComment     = dataTable.AsTableValuedParameter("dbo.ReviewCommentType"),
                        ApplicationUserId = applicationUserId
                    },
                        commandType : CommandType.StoredProcedure);
                }

                newReviewCommentId = newReviewCommentId ?? reviewCommentCreate.ReviewCommentId;

                ReviewComment reviewComment = await GetAsync(newReviewCommentId.Value);

                return(reviewComment);
            }
        }
Ejemplo n.º 16
0
        private async Task <IEnumerable <Message> > commentBodyAsync(ReviewComment reviewComment)
        {
            if (reviewComment == null)
            {
                return(null);
            }

            string jsonStrings;

            await using (FileStream fs = new FileStream(reviewComment.LogFilePath, FileMode.Open, FileAccess.Read))
            {
                using var sw = new StreamReader(fs);
                jsonStrings  = await sw.ReadToEndAsync();
            }

            var splitedJsonStrings = jsonStrings.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            var messages           = splitedJsonStrings.Select(item => JsonSerializer.Deserialize <Message>(item)).ToList();

            if (!messages.Any())
            {
                return(null);
            }
            return(messages);
        }
        public IHttpActionResult AddComment(Guid rid, [FromBody]ReviewCommentBM model)
        {
            DesignReview dbReview = UOW.DesignReviews.GetOwnById(rid, UserRecord.Id);
            if (dbReview == null)
            {
                return new SkyApiNotFound(Request);
            }
            ReviewDocument dbOption = UOW.ReviewDocuments.GetById(model.oid);
            if(dbOption == null)
            {
                return new SkyApiNotFound(Request);
            }

            if (dbReview.AcceptedDate != null)
            {
                ModelState.AddModelError("", "Review has been accepted and further changes are not allowed.");
                return new SkyApiBadRequest(Request, new SkyModelStateError(ModelState));
            }

            ReviewComment reviewComment = new ReviewComment
            {
                Comment = model.comment,
                // TODO: looks like a typo (OrderId should be OptionId)
                OrderId = dbOption.Id,
                DesignReviewId = rid,
                UserId = new Guid(UserRecord.Id),
                Username = UserRecord.UserName
            };
            dbReview.ReviewComments.Add(reviewComment);

            UOW.Commit();

            IDictionary<string, string> formData = new Dictionary<string, string>();
            formData.Add("User", UserRecord.FullName);
            formData.Add("Project", dbReview.Project.Name);
            formData.Add("Review", dbReview.Title);
            formData.Add("Option", dbOption.Title);
            formData.Add("Commment", model.comment);
            MailService.SendNotification(formData, "Skyberry Notification: New Comment");

            return new SkyApiPayload<ReviewCommentVM>(Request, ModelFactory.CreateReviewCommentVM(reviewComment));
        }
Ejemplo n.º 18
0
 public async Task Update([FromBody] ReviewComment review)
 {
     await reviewCommentService.UpdateAsync(review);
 }
        public void Can_save_review_comments()
        {
            var client = GetRepository();

            var    reviewId       = Guid.NewGuid().ToString();
            var    customerId     = Guid.NewGuid().ToString();
            Review dbReviewreview = new Review()
            {
                ReviewId        = reviewId,
                AuthorId        = customerId,
                AuthorLocation  = "Los Angeles",
                AuthorName      = "NickName",
                ItemId          = "someitem",
                ItemUrl         = "url",
                OverallRating   = 5,
                Title           = "comment",
                IsVerifiedBuyer = true,
                Status          = (int)ReviewStatus.Pending
            };

            client.Add(dbReviewreview);
            client.UnitOfWork.Commit();

            //RefreshClient
            RefreshRepository(ref client);

            var loadedReview = client.Reviews.Where(r => r.ReviewId == reviewId).SingleOrDefault();

            //client.Attach(loadedReview);

            ReviewComment reviewComment = new ReviewComment();

            reviewComment.AuthorId        = customerId;
            reviewComment.AuthorLocation  = "Los Angeles";
            reviewComment.AuthorName      = "Author";
            reviewComment.Comment         = "Comment";
            reviewComment.ReviewCommentId = Guid.NewGuid().ToString();
            reviewComment.Status          = (int)ReviewStatus.Pending;
            loadedReview.ReviewComments.Add(reviewComment);

            //client.Update(loadedReview);
            client.UnitOfWork.Commit();

            RefreshRepository(ref client);

            loadedReview = (from r in client.Reviews where r.ReviewId == reviewId select r).ExpandAll().SingleOrDefault();

            // test delete from collection, object should be removed from db as well
            loadedReview.ReviewComments.Remove(loadedReview.ReviewComments[0]);
            client.UnitOfWork.Commit();

            RefreshRepository(ref client);

            loadedReview = (from r in client.Reviews where r.ReviewId == reviewId select r).ExpandAll().SingleOrDefault();

            Assert.True(loadedReview.ReviewComments.Count == 0);

            // test saving just a comment by itself
            var reviewComment2 = new ReviewComment();

            reviewComment2.AuthorId        = customerId;
            reviewComment2.AuthorLocation  = "Los Angeles";
            reviewComment2.AuthorName      = "Author";
            reviewComment2.ReviewId        = reviewId;
            reviewComment2.Comment         = "Comment";
            reviewComment2.ReviewCommentId = Guid.NewGuid().ToString();
            reviewComment2.Status          = (int)ReviewStatus.Pending;
            client.Add(reviewComment2);
            client.UnitOfWork.Commit();

            var comment2 = (from r in client.ReviewComments where r.ReviewId == reviewId && r.ReviewCommentId == reviewComment2.ReviewCommentId select r).SingleOrDefault();

            Assert.True(comment2 != null);

            // now modify it
            reviewComment2.AuthorName = "Author2";
            client.UnitOfWork.Commit();

            comment2 = (from r in client.ReviewComments where r.ReviewId == reviewId && r.ReviewCommentId == reviewComment2.ReviewCommentId select r).SingleOrDefault();
            Assert.True(comment2 != null);
        }
Ejemplo n.º 20
0
 public async Task Insert([FromBody] ReviewComment review)
 {
     await reviewCommentService.InsertAsync(review);
 }
Ejemplo n.º 21
0
 public async Task UpdateAsync(ReviewComment reviewComment)
 {
     await repo.UpdateAsync(reviewComment);
 }
Ejemplo n.º 22
0
 public async Task InsertAsync(ReviewComment reviewComment)
 {
     await repo.InsertAsync(reviewComment);
 }
Ejemplo n.º 23
0
 public void Update(ReviewComment reviewComment)
 {
     repo.Update(reviewComment);
 }
Ejemplo n.º 24
0
 public void Insert(ReviewComment reviewComment)
 {
     repo.Insert(reviewComment);
 }
Ejemplo n.º 25
0
 public ReviewCommentVM CreateReviewCommentVM(ReviewComment item)
 {
     return new ReviewCommentVM
     {
         id = item.Id,
         comment = item.Comment,
         created = item.Created,
         oId = item.OrderId,
         rId = item.DesignReviewId,
         uId = item.UserId,
         uName = item.Username,
     };
 }