public async Task <IActionResult> PostItemToStore([FromBody] APIItem item, CancellationToken ct)
        {
            //TODO: Check to make sure the store is trying to add the item
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { error = "Model state is not valid" }));
            }

            var currentUser = HttpContext.User;
            var userclaim   = currentUser.Claims.First();
            var userId      = Guid.Parse(userclaim.Value);
            var storeUser   = await _storeUserRepository.GetEntityAsync(userId, ct);

            if (storeUser == null)
            {
                return(BadRequest(new { error = "Not a store, can't add items unless you are a store." }));
            }

            if (storeUser.HomeStoreId == 0)
            {
                return(BadRequest(new { error = "You are a store, but haven't created your homestore yet." }));
            }

            ItemEntity itemEntity = new ItemEntity
            {
                Name = item.Name,
                SpoonacularProductId = item.SpoonId
            };

            ItemStoreLinkEntity linkEntity = new ItemStoreLinkEntity
            {
                InStock     = item.InStock,
                StockAmount = item.StockAmount,
                StoreId     = storeUser.HomeStoreId,
                Price       = item.Price
            };

            bool itemAdded = await _itemRepository.AddEntityAsync(itemEntity, ct);

            if (itemAdded)
            {
                linkEntity.ItemId = itemEntity.Id;
                itemAdded         = await _itemStoreLinkRepository.AddEntityAsync(linkEntity, ct);

                if (itemAdded)
                {
                    return(Ok());
                }

                return(BadRequest());
            }

            return(BadRequest());
        }
        public async Task <IActionResult> PostStore([FromBody] APIStore apiStore, CancellationToken ct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { error = "Model state is not valid" }));
            }

            AddressEntity address = new AddressEntity
            {
                City      = apiStore.City,
                State     = apiStore.State,
                Street    = apiStore.Street,
                Latitude  = apiStore.Latitude,
                Longitude = apiStore.Longitude,
                Zip       = apiStore.Zip
            };

            var addressCreated = await _addressRepository.AddEntityAsync(address, ct);

            if (addressCreated)
            {
                StoreEntity store = new StoreEntity
                {
                    Name        = apiStore.Name,
                    PhoneNumber = apiStore.PhoneNumber,
                    Website     = apiStore.Website,
                    AddressId   = address.Id,
                    StoreUserId = apiStore.StoreUserId
                };

                var storeCreated = await _storeRepository.AddEntityAsync(store, ct);

                if (storeCreated)
                {
                    var storeUser = await _storeUserRepository.GetEntityAsync(apiStore.StoreUserId, ct);

                    storeUser.HomeStoreId = store.Id;
                    var updatedStoreUser = _storeUserRepository.UpdateEntity(storeUser, ct);

                    if (updatedStoreUser != null)
                    {
                        return(Ok($"store Created = {store}"));
                    }
                    return(Conflict("Unable to updated StoreUser"));
                }
                return(Conflict("Store was not created, but address was"));
            }

            return(Conflict("Store and address were not created"));
        }