コード例 #1
0
        public HttpResponseMessage CheckInPlace(string sessionKey, [FromBody] int?PlaceId)
        {
            User currentUser = userRepo.All().Where(u => u.SessionKey == sessionKey).FirstOrDefault();

            Place currentPlace = placeRepo.All().Where(p => p.Id == PlaceId).FirstOrDefault();

            if (currentUser == null || currentPlace == null)
            {
                return(this.Request.CreateErrorResponse(HttpStatusCode.NotFound, "User or Place wasn't found."));
            }

            currentUser.currentPlaceId = currentPlace.Id;
            currentUser.Latitude       = currentPlace.Latitude;
            currentUser.Longitude      = currentPlace.Longitude;

            userRepo.Update(currentUser.Id, currentUser);

            //PubNub information sending

            UserPlaceModel item = new UserPlaceModel(new UserModel(currentUser), new PlaceModel(currentPlace));

            SendPubnubMessage(item);

            return(this.Request.CreateResponse(HttpStatusCode.OK, string.Format("You successfully checked in : {0} !", currentPlace.Name)));
        }
コード例 #2
0
 private void SendPubnubMessage(UserPlaceModel item)
 {
     this.pubnub.Publish(this.channel, item);
 }