public IActionResult RemoveDislike([FromBody] LikeRequestModel model) { int userId = Convert.ToInt32(User.FindFirst("Id").Value); BlogLikeService.RemoveLike(model.Id, userId); return(Ok()); }
public async Task <ActionResult <bool> > Beat(LikeRequestModel model) { var isLiked = await this.likeService.VoteAsync(model.BeatId, this.currentUser.GetId()); // User receives a notification only when his beat is liked if (isLiked) { var producerOflikedBeat = await this.artistService.GetProducerByBeatIdAsync <ArtistByBeatIdServiceModel>(model.BeatId); // If user likes his own beat, he will not receive a notification if (producerOflikedBeat.ProducerId != this.currentUser.GetId()) { var beat = await this.beatService.DetailsAsync <BeatNameServiceModel>(model.BeatId); var notificationId = await this.notificationService.CreateAsync(producerOflikedBeat.ProducerId, this.currentUser.GetId(), string.Format(LikeNotification, this.currentUser.GetUserName(), beat.Name), "Like"); var notification = await this.notificationService.GetNotificationById <NotificationsByUserServiceModel>(notificationId); await this.notificationHub.Clients.User(producerOflikedBeat.ProducerId).SendAsync("NewNotificationReceived", notification); } } return(isLiked); }