public override async Task <Document> CreateItemAsync(Post newPost) { await _socialInteractionsDocumentDatabaseRepository.CreateItemAsync( new SocialInteractions { PostId = newPost.Id, TotalComments = 0, TotalLikes = 0 }); // If this is from a child var socialInteractions = await _socialInteractionsDocumentDatabaseRepository.GetItemsWhereAsync(itemFromDb => itemFromDb.PostId == newPost.ParentId.GetValueOrDefault()); var socialInteraction = socialInteractions.FirstOrDefault(); //TODO: Just check if Post.SocialInteraction is null, then create it yah? if (socialInteraction != null) { socialInteraction.TotalComments++; await _socialInteractionsDocumentDatabaseRepository.UpdateItemAsync(socialInteraction.Id.ToString(), socialInteraction); } return(await base.CreateItemAsync(newPost)); }
public async Task <Document> Post([FromBody] SocialInteractions value) { return(await _socialInteractionsRepository.CreateItemAsync(value)); }