public Task UpdateFeedItem(UpdateFeedItemViewModel model, string entityId, string userId)
        {
            var foundActiveFeed =
                _context.Set <FeedItem>().FirstOrDefault(x => x.IsActiveVersion && x.EntityId == entityId);

            if (foundActiveFeed == null)
            {
                return(Task.FromException(new Exception("FeedItem to update not found.")));
            }

            foundActiveFeed.IsActiveVersion = false;
            foundActiveFeed.Modified        = DateTime.Now;
            _context.Update(foundActiveFeed);
            _context.SaveChanges();

            var newFeed = foundActiveFeed;

            newFeed.Id = Guid.NewGuid().ToString();
            newFeed.IsActiveVersion = true;
            newFeed.Version         = GetNextVersion <FeedItem>(foundActiveFeed.EntityId);

            newFeed.CommentsEnabled = model.CommentsEnabled;
            newFeed.Content         = model.Content;
            newFeed.Title           = model.Title;
            newFeed.CommentsEnabled = model.CommentsEnabled;

            UpdateTagsIfChanged(newFeed.EntityId, model.Tags);

            _context.Add(newFeed);

            return(_context.SaveChangesAsync());
        }
Пример #2
0
        public async Task <IActionResult> Update([FromBody] UpdateFeedItemViewModel model)
        {
            var grain  = this._client.GetGrain <IManageContentGrain>(model.Id);
            var result = await grain.UpdateFeedItem(model);

            return(Json(result));
        }
        public async Task <string> UpdateFeedItem(UpdateFeedItemViewModel model)
        {
            var feedItem = await _context.Set <FeedItem>().FindAsync(model.Id);

            feedItem.CommentsEnabled = model.CommentsEnabled;
            feedItem.Description     = model.Description;
            feedItem.Title           = model.Title;

            var result = _context.Update(feedItem);

            await _context.SaveChangesAsync();

            return(result.Id);
        }
        public async Task <GrainOperationResult> UpdateFeedItem(UpdateFeedItemViewModel model, string entityId)
        {
            try
            {
                await _repository.UpdateFeedItem(model, entityId, GrainUserId);

                return(new GrainOperationResult {
                    Successful = true, Message = "Operation executed successfully."
                });
            }
            catch (Exception ex)
            {
                return(ex.ResultFromException());
            }
        }
 public async Task <string> UpdateFeedItem(UpdateFeedItemViewModel model)
 {
     return(await _updateRepository.UpdateFeedItem(model));
 }