Esempio n. 1
0
 public static void AddToReviewByDialog(int sentenceId)
 {
     Dictionary <int, Point> .Enumerator iter = Point.points.GetEnumerator();
     while (iter.MoveNext())
     {
         if (iter.Current.Value.sentenceId == sentenceId)
         {
             ReviewRecord reviewRecord;
             if (currentRole.reviews.ContainsKey(iter.Current.Value.id))
             {
                 reviewRecord        = currentRole.reviews[iter.Current.Value.id];
                 reviewRecord.times += 1;
             }
             else
             {
                 reviewRecord         = new ReviewRecord();
                 reviewRecord.times   = 1;
                 reviewRecord.pointId = iter.Current.Value.id;
                 currentRole.reviews.Add(reviewRecord.pointId, reviewRecord);
             }
             //Server.GetInstance().Submit(iter.Current.Value.id,Role.currentRole.isReview);
             reviewRecord.ticks = GetReviewTicks(reviewRecord.times);
             Review review = new Review(Role.currentRole.id, Role.sn, reviewRecord);
             string msg    = review.id + "|" + JsonMapper.ToJson(review);
             Debug.LogError(msg);
             (StudentLogin.GetInstance()).SendMsg(msg);
         }
     }
 }
Esempio n. 2
0
    public static void AddToReview(int pointId)
    {
        //Server.GetInstance().Submit(pointId,false);
        ReviewRecord reviewRecord;

        if (currentRole.reviews.ContainsKey(pointId))
        {
            reviewRecord        = currentRole.reviews[pointId];
            reviewRecord.times += 1;
        }
        else
        {
            reviewRecord         = new ReviewRecord();
            reviewRecord.times   = 1;
            reviewRecord.pointId = pointId;
            currentRole.reviews.Add(pointId, reviewRecord);
        }
        reviewRecord.ticks = GetReviewTicks(reviewRecord.times);

        reviewRecord.ticks = GetReviewTicks(reviewRecord.times);
        Review review = new Review(Role.currentRole.id, Role.sn, reviewRecord);
        string msg    = review.id + "|" + JsonMapper.ToJson(review);

        Debug.LogError(msg);
        (StudentLogin.GetInstance()).SendMsg(msg);
    }
        public ActionResult Create(int contentId, string comment, string returnUrl)
        {
            IUser currentUser = _orchardServices.WorkContext.CurrentUser;

            VoteRecord userVote = _votingService.Get(v => v.ContentItemRecord.Id == contentId && v.Username == currentUser.UserName).FirstOrDefault();

            if (userVote == null)
            {
                _orchardServices.Notifier.Error(T("In order to submit a review, you must also submit a rating."));
                TempData["Comment"] = comment;
            }
            else if (_reviewRepository.Fetch(r => r.VoteRecordId == userVote.Id).Any())
            {
                _orchardServices.Notifier.Error(T("You have already left a review for this item."));
            }
            else if (string.IsNullOrWhiteSpace(comment))
            {
                _orchardServices.Notifier.Error(T("Please fill out your comment before submitting your review."));
            }
            else if (comment.Length > 1200)
            {
                _orchardServices.Notifier.Error(T("Your comment must be less than 1,200 characters in length."));
                TempData["Comment"] = comment;
            }
            else
            {
                var review = new ReviewRecord {
                    Comment = comment, CreatedUtc = _clock.UtcNow, ContentItemRecordId = contentId, VoteRecordId = userVote.Id
                };
                _reviewRepository.Create(review);
                _orchardServices.Notifier.Information(T("Thank you for submitting your review."));
            }

            return(this.RedirectLocal(returnUrl, "~/"));
        }
Esempio n. 4
0
 public Review(int studentId, string vrNo, ReviewRecord reviewRecord, int id = 20) : base(id)
 {
     this.studentId = studentId;
     this.pointId   = reviewRecord.pointId;
     this.ticks     = reviewRecord.ticks;
     this.active    = reviewRecord.active;
     this.vrNo      = vrNo;
 }
        public async Task <ActionResult> Update(int id, [FromBody] ResolveViewModel model)
        {
            var existingEntity = await _resolvesService.GetByIdAsync(id);

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

            ValidateRequest(model);
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var resolve = model.MapEntity(_mapper, CurrentUserId);

            resolve.Reviewed = true;

            await _resolvesService.UpdateAsync(existingEntity, resolve);


            if (model.Attachments.HasItems())
            {
                var attachments = model.Attachments.Select(item => item.MapEntity(_mapper, CurrentUserId)).ToList();
                foreach (var attachment in attachments)
                {
                    attachment.PostType = PostType.Resolve;
                    attachment.PostId   = resolve.Id;
                }

                await _attachmentsService.SyncAttachmentsAsync(resolve, attachments);

                resolve.Attachments = attachments;
            }
            else
            {
                await _attachmentsService.SyncAttachmentsAsync(resolve, null);
            }

            var reviewRecord = new ReviewRecord {
                Reviewed = true, Type = ReviewableType.Resolve, PostId = resolve.Id
            };

            reviewRecord.SetCreated(CurrentUserId);
            await _reviewRecordsService.CreateAsync(reviewRecord);

            return(Ok());
        }
Esempio n. 6
0
        public BaseContent Review(User sender, int mark, string comment)
        {
            ReviewRecord record = new ReviewRecord
            {
                CreationDate  = DateTime.Now,
                Mark          = $"{mark}: {comment}",
                UserRecord    = sender.UserRecord,
                ContentRecord = Record
            };

            // Добавить ассоциации
            sender.UserRecord.ReviewRecord.Add(record);
            Record.ReviewRecord.Add(record);

            Manager.Container.ReviewRecordSet.Add(record);

            return(this);
        }
        public async Task <ActionResult> Store([FromBody] ResolveViewModel model)
        {
            ValidateRequest(model);
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var resolve = model.MapEntity(_mapper, CurrentUserId);

            resolve.Reviewed = true;
            resolve          = await _resolvesService.CreateAsync(resolve);

            if (model.Attachments.HasItems())
            {
                var attachments = model.Attachments.Select(item => item.MapEntity(_mapper, CurrentUserId)).ToList();
                foreach (var attachment in attachments)
                {
                    attachment.PostType = PostType.Resolve;
                    attachment.PostId   = resolve.Id;
                }

                _attachmentsService.CreateMany(attachments);

                resolve.Attachments = attachments;
            }

            var reviewRecord = new ReviewRecord {
                Reviewed = true, Type = ReviewableType.Resolve, PostId = resolve.Id
            };

            reviewRecord.SetCreated(CurrentUserId);
            await _reviewRecordsService.CreateAsync(reviewRecord);


            return(Ok(resolve.MapViewModel(_mapper)));
        }
Esempio n. 8
0
 internal Review(DatabaseManager man, ReviewRecord reviewRecord) :
     base(man)
 {
     ReviewRecord = reviewRecord;
 }
Esempio n. 9
0
 public async Task RemoveAsync(ReviewRecord record)
 {
     record.Removed = true;
     await _recordRepository.UpdateAsync(record);
 }
Esempio n. 10
0
 public async Task UpdateAsync(ReviewRecord existingEntity, ReviewRecord record) => await _recordRepository.UpdateAsync(existingEntity, record);
Esempio n. 11
0
 public async Task UpdateAsync(ReviewRecord record) => await _recordRepository.UpdateAsync(record);
Esempio n. 12
0
 public async Task <ReviewRecord> CreateAsync(ReviewRecord record) => await _recordRepository.AddAsync(record);