Esempio n. 1
0
 public static Comment ToCommentModel(this EditCommentRequest request)
 {
     return(new Comment
     {
         Body = request.Body
     });
 }
Esempio n. 2
0
 private void ChangeComment(Comment comment, string action)
 {
     if (comment is Comment emp_to_edit)
     {
         var notification = new ItemEditNotification(emp_to_edit);
         notification.Title = action + " Comment";
         EditCommentRequest.Raise(notification,
                                  r =>
         {
             if (r != null && r.Confirmed && r.EditibleObject != null)     //
             {
                 if (r.EditibleObject is Comment comm)
                 {
                     if (action == ApplicationStrings.NotificationEdit)
                     {
                         if (CommentSelectedItem is CommentWrapper comm_to_change)
                         {
                             comm_to_change.CommentType  = comm.CommentType;
                             comm_to_change.CommentValue = comm.CommentValue;
                         }
                     }
                     else
                     {
                         Account.Comments.Add(new CommentWrapper(comm));
                     }
                 }
             }
         });
     }
 }
Esempio n. 3
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "patch", Route = "interventions/{interventionId}/comments/{commentId}")]
            EditCommentRequest request,
            [Table(Config.InterventionsTableName, Connection = Config.StorageConnectionName)] CloudTable interventionsTable,
            string interventionId, string commentId, ILogger log)
        {
            var queryResult = await interventionsTable.ExecuteQuerySegmentedAsync(new TableQuery <InterventionEntity>().Where(
                                                                                      TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, interventionId)).Take(1), null);

            var requestedIntervention = queryResult.Results.FirstOrDefault();

            if (requestedIntervention == null)
            {
                return(new StatusCodeResult(StatusCodes.Status404NotFound));
            }

            try
            {
                requestedIntervention.EditComment(commentId, request.NewValue);
                await interventionsTable.ExecuteAsync(TableOperation.Merge(requestedIntervention));
            }
            catch (InvalidOperationException e)
            {
                return(new StatusCodeResult(StatusCodes.Status404NotFound));
            }

            return(new StatusCodeResult(StatusCodes.Status200OK));
        }
Esempio n. 4
0
        public static async Task <IActionResult> RunGeoHash(
            [HttpTrigger(AuthorizationLevel.Function, "patch", Route = "interventions/{latitude}/{longitude}/{interventionId}/comments/{commentId}")]
            EditCommentRequest request,
            [Table(Config.InterventionsTableName, Connection = Config.StorageConnectionName)] CloudTable interventionsTable,
            string latitude, string longitude, string interventionId, string commentId, ILogger log)
        {
            var geoHash     = GeoHasher.GetGeoHash(latitude, longitude);
            var finalFilter = InterventionFilterBuilder.GetInterventionGeoHashFilter(geoHash, interventionId);

            var queryResult = await interventionsTable.ExecuteQuerySegmentedAsync(new TableQuery <InterventionEntity>().Where(
                                                                                      finalFilter).Take(1), null);

            var requestedIntervention = queryResult.Results.FirstOrDefault();

            if (requestedIntervention == null)
            {
                return(new StatusCodeResult(StatusCodes.Status404NotFound));
            }

            try
            {
                requestedIntervention.EditComment(commentId, request.NewValue);
                await interventionsTable.ExecuteAsync(TableOperation.Merge(requestedIntervention));
            }
            catch (InvalidOperationException e)
            {
                return(new StatusCodeResult(StatusCodes.Status404NotFound));
            }

            return(new StatusCodeResult(StatusCodes.Status200OK));
        }
Esempio n. 5
0
        public async Task <ActionResult> EditComment(int id, [FromBody] EditCommentRequest request)
        {
            var commentModel = request.ToCommentModel();

            await _commentService.Edit(id, commentModel);

            return(NoContent());
        }
Esempio n. 6
0
        public ConfirmationResponse Execute(EditCommentRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var task    = _workTaskRepository.Read(request.WorkTaskId);
            var comment = _workTaskRepository.ReadComment(task.Id, request.CommentId);

            comment.Content = request.Content;
            _workTaskRepository.UpdateComment(comment);

            return(new ConfirmationResponse("Comment updated successfully.")
            {
                Id = task.Id,
            });
        }
        public void EditComment(EditCommentRequest request, ICommentsDataBaseSettings settings)
        {
            ConnectToDB(settings);
            String queryString = String.Format(MongoDbQuery.ParentID, request.Id);

            if (_mongoDatabase.GetCollection <AddComment>("messageThreads").Find(queryString).CountDocumentsAsync().Result == 0)
            {
                var filter = Builders <BsonDocument> .Filter.Eq("_id", new ObjectId(request.Id));

                var builderUpdate = Builders <BsonDocument> .Update.Set("comment", request.Comment);

                /*var updList = new List<UpdateDefinition<AddComment>>
                 * {
                 *   Builders<AddComment>.Update.Set(x => x.Comment, request.Comment)
                 * };
                 * var update = Builders<AddComment>.Update.Combine(updList);*/
                var collection = _mongoDatabase.GetCollection <BsonDocument>("messageThreads");
                var res        = collection.UpdateOne(filter, builderUpdate);
            }
        }
 public void EditComment(EditCommentRequest request)
 {
     _commentService.EditComment(request, _commentsDataBaseSettings);
 }