public IActionResult AddInteraction(int id, CreateInteractionRequestModel newInteraction)
        {
            var post = _posts.GetById(id);
            var user = _users.GetById(newInteraction.UserId);

            _interactions.Create(newInteraction, post, user);

            return(RedirectToAction("PostsPage"));
        }
Example #2
0
 public void Create(CreateInteractionRequestModel newInteraction, int postId)
 {
     _context.Interactions.Add(new Interaction
     {
         Type   = newInteraction.InteractionType,
         PostId = postId,
         UserId = newInteraction.UserId,
         Date   = DateTime.Now,
     });
     _context.SaveChanges();
 }
 public void Create(CreateInteractionRequestModel newInteraction, Post post, User user)
 {
     _context.Interactions.Add(new Interaction
     {
         Type = newInteraction.InteractionType,
         Post = post,
         User = user,
         Date = DateTime.Now,
     });
     _context.SaveChanges();
 }
Example #4
0
        public Post AddInteraction(int id, CreateInteractionRequestModel newInteraction)
        {
            var post = GetById(id);

            post.Interactions.Add(new Interaction
            {
                Type   = newInteraction.InteractionType,
                PostId = id,
                UserId = newInteraction.UserId,
                Date   = DateTime.Now,
            });
            _context.SaveChanges();

            return(post);
        }
Example #5
0
        public IActionResult AddInteraction([FromRoute] int id, CreateInteractionRequestModel newInteraction)
        {
            var post = _posts.AddInteraction(id, newInteraction);

            return(new OkObjectResult(post));
        }
Example #6
0
 public IActionResult AddInteraction(int id, CreateInteractionRequestModel newInteraction)
 {
     _interactions.Create(newInteraction, id);
     return(RedirectToAction("PostsPage"));
 }