コード例 #1
0
        public IActionResult SynchronizeData([FromRoute] string userId,
                                             [FromBody] SynchronisationRequest request)
        {
            SynchronisationRequest response = users.Synchronisation(userId, request);

            return(Ok(response));
        }
コード例 #2
0
ファイル: UserList.cs プロジェクト: xixsuse/ItHappened
        public SynchronisationRequest Synchronisation(string userId, SynchronisationRequest request)
        {
            var collection = db.GetCollection <User>("Users");
            var user       = collection.FindSync(us => us.UserId == userId).FirstAsync().Result;

            if (user.NicknameDateOfChange < request.NicknameDateOfChange)
            {
                user.NicknameDateOfChange = request.NicknameDateOfChange;
                user.UserNickname         = request.UserNickname;
            }

            List <Tracking> collectionToReturn = user.ChangeTrackingCollection(request.TrackingCollection);

            var filter = Builders <User> .Filter.Eq(us => us.UserId, user.UserId);

            collection.ReplaceOneAsync(filter, user);

            SynchronisationRequest toReturn = new SynchronisationRequest()
            {
                NicknameDateOfChange = user.NicknameDateOfChange,
                UserNickname         = user.UserNickname,
                TrackingCollection   = collectionToReturn
            };

            return(toReturn);
        }
コード例 #3
0
        public IActionResult TestSync([FromRoute] string userId, [FromBody] SynchronisationRequest request)
        {
            if (!_manager.FindUser(userId))
            {
                return(BadRequest("User does not exist"));
            }

            var response = _manager.SynchronizeData(userId, request.NicknameDateOfChange,
                                                    userId, request.trackingCollection);

            return(Ok(response));
        }
コード例 #4
0
        public IActionResult SynchronizeData([FromBody] SynchronisationRequest request)
        {
            var userId = HttpContext.GetUserId();

            if (!_manager.FindUser(userId))
            {
                return(BadRequest("User does not exist"));
            }

            var response = _manager.SynchronizeData(userId, request.NicknameDateOfChange,
                                                    request.UserNickname, request.trackingCollection);

            return(Ok(response));
        }
コード例 #5
0
        public SynchronisationRequest SynchronizeData(string userId, DateTimeOffset nicknameDateOfChange,
                                                      string userNickname, List <Tracking> trackingCollection)
        {
            var user = _userRepository.GetUserData(userId);

            if (user.NicknameDateOfChange < nicknameDateOfChange)
            {
                user.NicknameDateOfChange = nicknameDateOfChange;
                user.UserNickname         = userNickname;
            }

            List <Tracking> collectionToReturn = user.ChangeTrackingCollection(trackingCollection);

            _userRepository.SaveUserData(user);

            SynchronisationRequest toReturn = new SynchronisationRequest()
            {
                NicknameDateOfChange = user.NicknameDateOfChange,
                UserNickname         = user.UserNickname,
                trackingCollection   = collectionToReturn
            };

            return(toReturn);
        }