Beispiel #1
0
        private SharedApi.UpsertBucketListItemRequest CreateAddEditRequest
        (
            SharedBucketListModel bucketListItem,
            string encodedUserName,
            string encodedToken,
            bool isAdd
        )
        {
            var request = new SharedApi.UpsertBucketListItemRequest()
            {
                Token = new SharedApi.TokenRequest()
                {
                    EncodedToken    = encodedToken,
                    EncodedUserName = encodedUserName
                },
                BucketListItem = new BucketListItem()
                {
                    Name      = bucketListItem.Name,
                    Created   = System.DateTime.UtcNow,
                    Category  = bucketListItem.BucketListItemType.ToString(),
                    Achieved  = bucketListItem.Completed,
                    Latitude  = System.Convert.ToDecimal(bucketListItem.Latitude),
                    Longitude = System.Convert.ToDecimal(bucketListItem.Longitude),
                    Id        = isAdd ? (int?)null : System.Convert.ToInt32(bucketListItem.DatabaseId)
                }
            };

            return(request);
        }
Beispiel #2
0
        private List <SharedBucketListModel> Convert(List <BucketListItem> bucketListItems, string encodedUserName)
        {
            var convertedBucketListItems = new List <SharedBucketListModel>();

            foreach (var bucketListItem in bucketListItems)
            {
                var convertedBucketListItem = new SharedBucketListModel()
                {
                    Name               = bucketListItem.Name,
                    DateCreated        = bucketListItem.Created.ToString(),
                    BucketListItemType = (SharedMisc.Enums.BucketListItemTypes)Enum.Parse(
                        typeof(SharedMisc.Enums.BucketListItemTypes),
                        bucketListItem.Category),
                    Completed  = bucketListItem.Achieved,
                    Latitude   = bucketListItem.Latitude.ToString(),
                    Longitude  = bucketListItem.Longitude.ToString(),
                    DatabaseId = bucketListItem.Id.HasValue ? bucketListItem.Id.ToString() : null,
                    UserName   = Shared.misc.Utilities.DecodeClientBase64String(encodedUserName),
                };

                convertedBucketListItems.Add(convertedBucketListItem);
            }

            return(convertedBucketListItems);
        }
Beispiel #3
0
        public bool EditBucketListItem(SharedBucketListModel bucketListItem, string encodedUserName, string encodedToken)
        {
            var request = CreateAddEditRequest(bucketListItem, encodedUserName, encodedToken, false);

            var json    = JsonConvert.SerializeObject(request);
            var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
            var url     = host + "/api/tgimbaapi/upsert";

            var result = httpClient.Post(url, content);

            bool updated = System.Convert.ToBoolean(result);

            return(updated);
        }
Beispiel #4
0
        protected SharedBucketListModel GetBucketListItemModel(string userName, string listItemName = "", string dbIdStr = "", bool extended = false)
        {
            SharedBucketListModel model = new SharedBucketListModel
            {
                Name               = listItemName,
                DateCreated        = "12/15/2010",
                BucketListItemType = Shared.misc.Enums.BucketListItemTypes.Hot, // TODO - set
                Completed          = true,
                Latitude           = "123.333",
                Longitude          = "555.1345",
                DatabaseId         = dbIdStr,
                UserName           = userName
            };

            return(model);
        }
        // TODO - temp solution - figure out why Vanilla javascript model has null values
        private SharedBucketListModel ConvertArgsToModel(string Name, string DateCreated, string BucketListItemType, string Completed,
                                                         string Latitude, string Longitude, string DatabaseId, string UserName)
        {
            var model = new SharedBucketListModel()
            {
                Name               = Name,
                DateCreated        = DateCreated,
                BucketListItemType = Utilities.ConvertCategoryToEnum(BucketListItemType),
                Completed          = System.Convert.ToBoolean(Completed),
                Latitude           = Latitude,
                Longitude          = Longitude,
                DatabaseId         = DatabaseId,
                UserName           = UserName
            };

            return(model);
        }
Beispiel #6
0
        public static string ConvertModelToString(SharedBucketListModel model)
        {
            string bucketListItem = null;

            if (model != null)
            {
                bucketListItem  = "," + model.Name + ",";                         // leading comma is for tgimba service
                bucketListItem += model.DateCreated + ",";
                bucketListItem += model.BucketListItemType.ToString() + ",";
                bucketListItem += model.Completed == true ? "1,":"0,";
                bucketListItem += model.Latitude + ",";
                bucketListItem += model.Longitude + ",";
                bucketListItem += model.DatabaseId + ",";
                bucketListItem += model.UserName;
            }

            return(bucketListItem);
        }
        public bool EditBucketListItem(SharedBucketListModel model, string encodedUser, string encodedToken)
        {
            var itemEdited = webClient.EditBucketListItem(model, encodedUser, encodedToken);

            return(itemEdited);
        }