Esempio n. 1
0
        public async Task <IActionResult> Create([FromBody] CreateFeedItemViewModel model)
        {
            var grain  = this._client.GetGrain <IManageContentGrain>(Guid.NewGuid().ToString());
            var result = await grain.CreateFeedItem(model);

            return(Json(result));
        }
Esempio n. 2
0
        public async Task <GrainOperationResult> CreateFeedItem(CreateFeedItemViewModel model, string feedId)
        {
            try
            {
                await _repository.CreateFeedItem(model, feedId, GrainUserId);

                return(new GrainOperationResult {
                    Successful = true, Message = "Operation executed successfully."
                });
            }
            catch (Exception ex)
            {
                return(ex.ResultFromException());
            }
        }
Esempio n. 3
0
        public async Task <string> CreateFeedItem(CreateFeedItemViewModel model, string feedId, string userId)
        {
            var feedItem = new FeedItem(feedId, model.Title, model.Description, model.Content, model.CommentsEnabled);

            if (model.Tags != null && model.Tags.Any())
            {
                var tags = model.Tags.AsTagsEnumerable(feedItem.EntityId);
                _context.AddRange(tags);
            }

            _context.Add(feedItem);

            await _context.SaveChangesAsync();

            return(feedItem.EntityId);
        }
        public async Task <string> CreateFeedItem(CreateFeedItemViewModel model)
        {
            var tags = model.Tags?.Select(name => new Tag(name)).ToList();

            var feedItem = new FeedItem(model.FeedId, model.Title)
            {
                Content     = new Content(model.Content),
                Description = model.Description,
                Tags        = tags
            };

            var result = _context.Add(feedItem);
            await _context.SaveChangesAsync();

            return(result.Id);
        }
 public async Task <string> CreateFeedItem(CreateFeedItemViewModel model)
 {
     return(await _createRepository.CreateFeedItem(model));
 }