// POST api/itemexclusion/PostItemExclusion
        public HttpResponseMessage PostItemExclusion(API_ItemExclusion itemExclusion)
        {
            var rcMsg = Request.CreateResponse(HttpStatusCode.BadRequest);
            if ((ModelState.IsValid) && ((!string.IsNullOrEmpty(itemExclusion.ListSharePublicKey)) && (!string.IsNullOrEmpty(itemExclusion.ItemPublicKey))))
            {
                try
                {
                    using (var dataMethods = new DataMethods())
                    {
                        var listShareID = dataMethods.ListShare_GetByPublicKey(itemExclusion.ListSharePublicKey).ListShareID;
                        var itemID = dataMethods.ListItem_GetByPublicKey(itemExclusion.ItemPublicKey).ItemID;
                        var rcItemExclusion = dataMethods.ItemExclusion_Create(listShareID, itemID);
                        if (rcItemExclusion != null)
                        {
                            rcMsg = Request.CreateResponse(HttpStatusCode.Created, rcItemExclusion);
                        }
                    }
                }
                catch (Exception ex)
                {
                    rcMsg = Request.CreateResponse(HttpStatusCode.BadRequest);
                }
            }
            else
            {
                rcMsg = Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            return rcMsg;
        }
示例#2
0
        public List<API_List> GetUserLists(string userPublicKey)
        {
            var rcList = new List<API_List>();
            try
            {
                //
                using (_dataAccess = new DataMethods())
                {
                    var usr = _dataAccess.User_GetUser(userPublicKey);
                    if (usr != null)
                    {
                        var converter = new API_List();
                        var usrLists = _dataAccess.List_GetListByUserID(usr.UserID);
                        foreach (var l in usrLists)
                        {
                            rcList.Add(converter.ConvertToAPI_ListWithAllItems(l));
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to source User: " + userPublicKey);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return rcList;
        }
        public HttpResponseMessage DeleteItemExclusion(string id)
        {
            var rcMsg = Request.CreateResponse(HttpStatusCode.OK);
            if (!string.IsNullOrEmpty(id))
            {
                try
                {
                    using (var dataMethods = new DataMethods())
                    {
                        var rcItemExclusion = dataMethods.ItemExclusion_Delete(id);
                        if (!rcItemExclusion)
                        {
                            Request.CreateResponse(HttpStatusCode.BadRequest);
                        }
                    }
                }
                catch (Exception ex)
                {
                    rcMsg = Request.CreateResponse(HttpStatusCode.BadRequest);
                }
            }
            else
            {
                rcMsg = Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            return rcMsg;
        }
示例#4
0
        private static bool CreateEmailAddress(string userPublicKey, string emailAddress)
        {
            var rc = false;

            using(gData = new DataMethods())
            {
                gData.User_CreateEmail(userPublicKey, emailAddress);
            }

            return rc;
        }
示例#5
0
        private static bool CreateItemExclusion_nonAPI(API_ItemExclusion itemExclusion)
        {
            var rc = false;
            using (DataMethods dataMethods = new DataMethods())
            {
                var listShareID = dataMethods.ListShare_GetByPublicKey(itemExclusion.ListSharePublicKey).ListShareID;
                var itemID = dataMethods.ListItem_GetByPublicKey(itemExclusion.ItemPublicKey).ItemID;

                var newItemExclusion = dataMethods.ItemExclusion_Create(listShareID, itemID);
                if (newItemExclusion != null)
                {
                    rc = true;
                }
            }

            return rc;
        }
示例#6
0
        // GET api/ListItem/GetItem/5
        public API_ListItem GetItem(string id)
        {
            API_ListItem returnItem = new API_ListItem();

            using (_dataMethods = new DataMethods())
            {
                var item = _dataMethods.ListItem_GetByPublicKey(id);
                if (item == null)
                {
                    throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
                }
                else
                {
                    returnItem = returnItem.ConvertToAPI_ListItem(item, item.List.PublicKey);
                }
            }

            return returnItem;
        }
示例#7
0
        // GET api/ListItem/GetItems
        public List<API_ListItem> GetItems()
        {
            List<API_ListItem> returnItems = new List<API_ListItem>();

            try
            {
                using (_dataMethods = new DataMethods())
                {
                    var listItems = _dataMethods.ListItem_GetAll();
                    foreach (var i in listItems)
                    {
                        returnItems.Add(converter.ConvertToAPI_ListItem(i,i.List.PublicKey));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return returnItems;
        }
示例#8
0
 private static List UpdateListByPublicKey(string publicKey, string newTitle, string newDescription)
 {
     gData = new DataMethods();
     return gData.List_UpdateList(publicKey, newTitle, newDescription);
 }
示例#9
0
        private static void SeeAllLists()
        {
            gData = new DataMethods();
            foreach(var l in gData.List_GetAllLists())
            {
                Console.WriteLine(string.Format("{0} ({1}) with {2} items.",l.Title,l.PublicKey, l.Items.Count.ToString()));
            }

            Console.Read();
        }
示例#10
0
 private static List<Item> ReorderListItemsByListPublicKey(string listPublicKey)
 {
     gData = new DataMethods();
     return gData.ListItem_ReorderByOrdinalForList(listPublicKey);
 }
示例#11
0
        private static GyftoList.Data.User CreateUserAccount(string fName, string lName, string password, string emailAddress, string providerType, int? birthYear, string avatarUrl)
        {
            GyftoList.Data.User rc;

            using (gData = new DataMethods())
            {
                rc = gData.User_CreateUser(fName, lName, password, emailAddress, providerType, birthYear, avatarUrl);
            }

            return rc;
        }
示例#12
0
        private static int QueryEmailAddresses()
        {
            var rc = 0;

            using (gData = new DataMethods())
            {
                gData.User_EmailCount("*****@*****.**");
            }

            return rc;
        }
示例#13
0
        private static GyftoList.Data.User LoginUser(string emailAddress, string password)
        {
            GyftoList.Data.User returnUser = null;
            using (gData = new DataMethods())
            {
                // TODO - MAKE THIS LESS AMBIGUOUS
                //returnUser = gData.User_Login(emailAddress, password);
            }

            return returnUser;
        }
示例#14
0
        private static bool DeleteListItem(string publicKey)
        {
            gData = new DataMethods();

            return gData.ListItem_Delete(publicKey);
        }
示例#15
0
        /// <summary>
        /// This builds a base/shell API_ListShare object
        /// </summary>
        /// <param name="listShare"></param>
        /// <returns></returns>
        private API_ListShare GetShellListShare(ListShare listShare)
        {
            var apiShare = new API_ListShare();
            var apiUsr = new API_User();
            var apiList = new API_List();
            DataMethods _dataMethods = new DataMethods();
            var uConsumerObj = _dataMethods.User_GetUser(listShare.ConsumerID);
            var oConsumerObj = _dataMethods.User_GetUser(listShare.OwnerID);

            var uConsumer = apiUsr.ConvertToAPI_UserWithoutAssociatedLists(uConsumerObj);
            var uOwner = apiUsr.ConvertToAPI_UserWithoutAssociatedLists(oConsumerObj);

            apiShare.PublicKey = listShare.PublicKey;
            apiShare.ConsumerPublicKey = uConsumer.PublicKey;
            apiShare.OwnerPublicKey = uOwner.PublicKey;
            apiShare.ConsumerDisplayName = uConsumer.DisplayName;
            apiShare.OwnerDisplayName = uOwner.DisplayName;

            return apiShare;
        }
示例#16
0
 private static Item UpdateListItem(Item updatedItem, string itemPublicKey)
 {
     gData = new DataMethods();
     return gData.ListItem_UpdateItem(updatedItem, itemPublicKey);
 }
示例#17
0
 private static List CreateList()
 {
     gData = new DataMethods();
     // c6e4d6de
     return gData.List_CreateList("Espresso Machines", "Different types/brands of Espresso machines by amount", "49c8f932");
 }
示例#18
0
 private static List<Item> GetListItemsForList(string listPublicKey)
 {
     gData = new DataMethods();
     return gData.ListItem_GetAllByListPublicKey(listPublicKey);
 }
示例#19
0
 private static Item GetListItemByDisplayOrdinal(string listPublicKey, int listItemDisplayOrdinal)
 {
     gData = new DataMethods();
     return gData.ListItem_GetByActiveAndDisplayOrdinal(listPublicKey, listItemDisplayOrdinal);
 }
示例#20
0
 private static int GetItemsCountForList(string listPublicKey)
 {
     gData = new DataMethods();
     return gData.ListItem_GetAllByListPublicKey(listPublicKey).Count();
 }
示例#21
0
 private static List<GyftoList.Data.User> GetAllConsumersOfListItem(string listItemPublicKey)
 {
     gData = new DataMethods();
     return gData.ListItem_GetAllConsumersByListItemPublicKey(listItemPublicKey);
 }
示例#22
0
        private static Item Deprecated_CreateListItem(string listPublicKey)
        {
            gData = new DataMethods();

            //string listPublicKey = "49c8f932"; // MAIN XMAS LIST
            //string listPublicKey = "c6e4d6de"; // STOCKING STUFFER LIST
            //string listPublicKey = "9634ec5"; // KELLI'S LIST
            //string listPublicKey = "1a292692"; // ESPRESSO MACHINES
            string itemTitle = "PlaySeat Challenge";
            string itemDescription = "Seat for racing/gaming console";
            string itemURL = "http://www.playseat.com/shop/us/us/playseat-challenge-seats/playseat-challenge-racing-seat.html";
            string itemImageURL = "http://www.playseat.com/page_content_files/shop_content_images/challenge-seat2.jpg";
            string itemSize = string.Empty;
            string itemColor = string.Empty;
            short itemQty = 1;
            decimal itemCost = 249.00m;
            decimal itemCostRangeStart = 0.00m;
            decimal itemCostRangeEnd = 0.00m;

            return gData.ListItem_Create(listPublicKey, itemTitle, itemDescription, itemCost, itemCostRangeStart, itemCostRangeEnd, itemSize, itemColor, itemQty, null, itemImageURL, itemURL);
        }
示例#23
0
 private static void UpdateListItemOrdinal(int currentItemDisplayOrdinal, int replaceItemDisplayOrdinal, string listPublicKey)
 {
     gData = new DataMethods();
     var rc = gData.ListItem_ReorderItem(currentItemDisplayOrdinal, replaceItemDisplayOrdinal, listPublicKey);
 }
示例#24
0
 private static List<ListShare> GetListShares()
 {
     gData = new DataMethods();
     return gData.ListShare_GetAll();
 }
示例#25
0
 public ListController()
 {
     _dataAccess = new DataMethods();
 }
示例#26
0
 private static GyftoList.Data.User GetUserByEmailAddress(string emailAddress)
 {
     gData = new DataMethods();
     return gData.User_GetUserByEmail(emailAddress);
 }
示例#27
0
 public UserController()
 {
     _dataAccess = new DataMethods();
 }
示例#28
0
 private static GyftoList.Data.User GetUserByPublicKey(string userPublicKey)
 {
     gData = new DataMethods();
     return gData.User_GetUser(userPublicKey);
 }
示例#29
0
 public ListShare ConvertFromAPI_ListShare(API_ListShare listShare)
 {
     using(var dataMethods = new DataMethods())
     {
         return new ListShare() {
             List = dataMethods.List_GetListByPublicKey(listShare.SharedList.PublicKey)
             ,UserConsumer = dataMethods.User_GetUser(listShare.ConsumerPublicKey)
             ,UserOwner = dataMethods.User_GetUser(listShare.OwnerPublicKey)
         };
     }
 }
示例#30
0
 private static List<GyftoList.Data.User> GetUsers()
 {
     gData = new DataMethods();
     return gData.User_GetAllUsers();
 }