public IHttpActionResult Add(AddLikeRequest addLikeRequest) { using (var context = new VKLikeContext()) { context.Likes.Add(new Like { DateTime = addLikeRequest.DateTime, Page = addLikeRequest.Page }); context.SaveChanges(); } return(Ok()); }
public void Should_serialize_request_the_same_way_as_in_snapshot() { var testRequest = new AddLikeRequest { AggregateId = this.aggregateId, Id = this.id, ObjectType = this.testObkectType }; var json = this.serialiser.Serialize(testRequest, this.testUserId); json.Should().Be(this.snapshot); }
public HttpResponseMessage AddCommentLike(AddLikeRequest request) { if (request == null) { return(new HttpResponseMessage(HttpStatusCode.UnsupportedMediaType)); } var userId = ClaimsPrincipal.Current.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value ?? "0"; var like = _likeRepository.GetLikeByCommentId(request.CommentId, Int32.Parse(userId)); if (like == null) { var preparedLike = PrepareCommentLikeToBeAdded(request.CommentId, request.Value, Int32.Parse(userId)); _likeRepository.AddLike(preparedLike); } else { like.Value = request.Value; _likeRepository.UpdateLike(like); } return(new HttpResponseMessage(HttpStatusCode.OK)); }
// user1 creates a topic. user2 likes it. user3 likes it. // get the like feed, and check the user names. check the like count. // clean up - delete the topic. public async Task DoLikeFeedTest() { // step 1, create a topic AddTopicRequest addTopicRequest = new AddTopicRequest(user1req) { TopicCategory = "Photo", TopicFriendlyName = "abcdef", TopicTitle = "Rarest coin", TopicText = "Egyptian coin", TopicBlobType = (int)BlobType1.Image, TopicBlobUrl = "http://coinquest.com/cgi-data/cq_ro/response_380/egypt_10_milliemes_1958.jpg", TopicDeepLink = "coins:abcdef", TopicType = (int)TopicType.New }; AddTopicResponse addResponse = await ServerTask <AddTopicRequest, AddTopicResponse> .PostRequest(addTopicRequest); //Assert.AreEqual(addResponse.ResponseCode, ResponseCode.Success); // extract topic handle from the response this.TopicHandle = addResponse.TopicHandle; Console.WriteLine("LikeFeedTest: Added topic"); await Task.Delay(Constants.ServiceWriteDelay); // user2 likes the topic AddLikeRequest addLikeRequest = new AddLikeRequest(user2req) { ContentHandle = this.TopicHandle, ContentType = (int)ContentType1.Topic, SequenceId = Environment.TickCount }; AddLikeResponse addLikeResponse = await ServerTask <AddLikeRequest, AddLikeResponse> .PostRequest(addLikeRequest); //Assert.AreEqual(addLikeResponse.ResponseCode, ResponseCode.Success); Console.WriteLine("LikeFeedTest: user2 liked topic"); await Task.Delay(Constants.ServiceWriteDelay); // user3 likes the topic addLikeRequest = new AddLikeRequest(user3req) { ContentHandle = this.TopicHandle, ContentType = (int)ContentType1.Topic, SequenceId = Environment.TickCount }; addLikeResponse = await ServerTask <AddLikeRequest, AddLikeResponse> .PostRequest(addLikeRequest); //Assert.AreEqual(addLikeResponse.ResponseCode, ResponseCode.Success); Console.WriteLine("LikeFeedTest: user3 liked topic"); await Task.Delay(Constants.ServiceWriteDelay); // get the like feed for the topic GetLikeFeedRequest getLikesReq = new GetLikeFeedRequest() { ContentHandle = this.TopicHandle, BatchSize = 10 }; GetLikeFeedResponse getLikesResponse = await ServerTask <GetLikeFeedRequest, GetLikeFeedResponse> .PostRequest(getLikesReq); //Assert.AreEqual(getLikesResponse.ResponseCode, ResponseCode.Success); Console.WriteLine("Likes list:"); foreach (var user in getLikesResponse.Users) { Console.WriteLine("User = {0}", user.UserHandle); } }
public async Task <IActionResult> Add([FromBody] AddLikeRequest request) { await this.requestQueuer.QueueRequest(request, this.GetUserId()); return(this.Accepted(request.Id)); }
public HttpResponseMessage AddCommentLike([FromBody] AddLikeRequest request) { return(_likeAddModule.AddCommentLike(request)); }