Exemplo n.º 1
0
        public string[] GetBucketListItems(string encodedUserName, string encodedSortString, string encodedToken)
        {
            IBucketListData bld = null;

            string[] result = null;

            try
            {
                bld = new BucketListData(Utilities.GetDbSetting());

                string decodedUserName   = Utilities.DecodeClientBase64String(encodedUserName);
                string decodedSortString = Utilities.DecodeClientBase64String(encodedSortString);
                string decodedToken      = Utilities.DecodeClientBase64String(encodedToken);

                //LogParameters();

                if (ProcessToken(decodedUserName, decodedToken))
                {
                    result = bld.GetBucketList(decodedUserName, decodedSortString);
                }
                else
                {
                    result = Utilities.GetInValidTokenResponse();
                }
            }
            catch (Exception e)
            {
                bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString());
            }

            return(result);
        }
Exemplo n.º 2
0
        public void User_DeleteUserBucketListItems_OnlyDeleteBucketListItems_Test()
        {
            var             userName = "******";
            IBucketListData bd       = new BucketListData(this.GetDbContext(true), this.userHelper);
            List <User>     users    = new List <User>();

            var userId1 = bd.AddUser(GetUser("token1", userName));
            var userId2 = bd.AddUser(GetUser("token2", userName));
            var userId3 = bd.AddUser(GetUser("token3", userName));

            bd.AddToken(userId1, "token1");
            bd.AddToken(userId2, "token2");
            bd.AddToken(userId3, "token3");

            var bucketListItems = GetBucketListItems();

            foreach (var bucketListItem in bucketListItems)
            {
                bd.UpsertBucketListItem(bucketListItem, userName);
            }

            AssertUsersExist(true, true, bd, userName);

            bd.DeleteUserBucketListItems(userName, true);

            var bucketListItemSaved = bd.GetBucketList(userName);

            Assert.IsFalse(bucketListItemSaved.Count > 0);
            var savedUsers = bd.GetUsers("testUser");

            Assert.IsTrue(savedUsers.Count > 0);
        }
Exemplo n.º 3
0
        public string[] GetBucketListItems(string encodedUserName, string encodedSortString, string encodedToken)
        {
            IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN));
            string[] result = null;

            try
            {
                string decodedUserName = Utility.DecodeClientBase64String(encodedUserName);
                string decodedSortString = Utility.DecodeClientBase64String(encodedSortString);
                string decodedToken = Utility.DecodeClientBase64String(encodedToken);

                IList<string> parameters = new List<string>();
                parameters.Add(decodedUserName);
                parameters.Add(decodedSortString);
                CommonCode.Log(null, bld, "GetBucketListItems", parameters);

                if (ProcessToken(decodedUserName, decodedToken))
                    result = bld.GetBucketList(decodedUserName, decodedSortString);
                else
                {
                    result = Utility.GetInValidTokenResponse();
                }
            }
            catch (Exception e)
            {
                bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString());
            }

            return result;
        }
Exemplo n.º 4
0
        public string[] GetBucketListItems(string encodedUserName, string encodedSortString, string encodedToken)
        {
            IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN));

            string[] result = null;

            try
            {
                string decodedUserName   = Utility.DecodeClientBase64String(encodedUserName);
                string decodedSortString = Utility.DecodeClientBase64String(encodedSortString);
                string decodedToken      = Utility.DecodeClientBase64String(encodedToken);

                IList <string> parameters = new List <string>();
                parameters.Add(decodedUserName);
                parameters.Add(decodedSortString);
                CommonCode.Log(null, bld, "GetBucketListItems", parameters);

                if (ProcessToken(decodedUserName, decodedToken))
                {
                    result = bld.GetBucketList(decodedUserName, decodedSortString);
                }
                else
                {
                    result = Utility.GetInValidTokenResponse();
                }
            }
            catch (Exception e)
            {
                bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString());
            }

            return(result);
        }
        public void BucketListItem_HappyPath_Test()
        {
            // set up ------------------------------------------------------
            RemoveTestUser();

            var             user = GetUser("token");
            IBucketListData bd   = new BucketListData(this.GetDbContext(true), this.userHelper);
            var             bucketListItemToSave = GetBucketListItem();

            // test ---------------------------------------------------------
            var userId = bd.AddUser(user);

            bd.UpsertBucketListItem(bucketListItemToSave, user.UserName);
            var savedBucketListItem = bd.GetBucketList(user.UserName).FirstOrDefault();

            // we have a saved object that object matches our created object
            Assert.IsNotNull(savedBucketListItem);
            Assert.AreEqual(bucketListItemToSave.Name, savedBucketListItem.Name);
            Assert.AreEqual(bucketListItemToSave.Created, savedBucketListItem.Created);
            Assert.AreEqual(bucketListItemToSave.Category, savedBucketListItem.Category);
            Assert.AreEqual(bucketListItemToSave.Achieved, savedBucketListItem.Achieved);
            Assert.AreEqual(bucketListItemToSave.Latitude, savedBucketListItem.Latitude);
            Assert.AreEqual(bucketListItemToSave.Longitude, savedBucketListItem.Longitude);

            // we can update that object and save it
            // TODO - upsert update part not working...fix
            savedBucketListItem.Name = savedBucketListItem.Name + " modified";
            bd.UpsertBucketListItem(savedBucketListItem, user.UserName);
            var savedBucketListItemUpdated = bd.GetBucketList(user.UserName).FirstOrDefault();

            Assert.AreEqual(savedBucketListItem.Name, savedBucketListItemUpdated.Name);

            // we can delete the bucket list item
            bd.DeleteBucketListItem(savedBucketListItemUpdated.Id.Value);
            var deletedBucketListItem = bd.GetBucketList(user.UserName).FirstOrDefault();

            Assert.IsNotNull(savedBucketListItem);

            //clean up user
            bd.DeleteUser(userId);
        }