Inheritance: MonoBehaviour
示例#1
0
        public List <StoreProduct> GetProductsInStore(String storeID)
        {
            DataTable dataTable = queries.GetProductsInStore(storeID);

            if (dataTable == null)
            {
                return(null);
            }
            List <StoreProduct> storeProductList = new List <StoreProduct>();

            foreach (DataRow row in dataTable.Rows)
            {
                String[] tpStr = new String[dataTable.Columns.Count];
                int      i     = 0;
                foreach (DataColumn col in dataTable.Columns)
                {
                    tpStr[i] = row[col].ToString();
                    i++;
                }
                StoreProduct tempData = new StoreProduct();
                tempData.Handler(tpStr);
                storeProductList.Add(tempData);
            }

            return(storeProductList);
        }
示例#2
0
 public AddOnItem(StoreProduct product)
 {
     Title          = product.Title;
     Description    = product.Description;
     FormattedPrice = product.Price.FormattedPrice;
     this.product   = product;
 }
        public ActionResult _Create(Guid batchid)
        {
            StoreProduct storeProduct = new StoreProduct();

            storeProduct.BatchId = batchid;
            return(PartialView("_Create", storeProduct));
        }
示例#4
0
        //查找产品订阅信息
        private async Task <StoreProduct> GetSubscriptionProductAsync()
        {
            //加载此应用程序的可销售外接程序,并检查试用是否仍然存在
            //这个客户可以使用。如果他们以前获得过审判,他们就不会。
            //能够再次获得试用,Store..Skus属性将
            //仅包含一个SKU。
            StoreProductQueryResult result =
                await context.GetAssociatedStoreProductsAsync(new string[] { "Durable" });

            if (result.ExtendedError != null)
            {
                Loading.IsActive = false;
                var messageDig1 = new MessageDialog("获得此订阅时出现了一些问题。");
                //展示窗口,获取按钮是否退出  
                var result1 = await messageDig1.ShowAsync();

                return(null);
            }
            //查找表示订阅的产品。
            foreach (var item in result.Products)
            {
                StoreProduct product = item.Value;
                if (product.StoreId == productID)
                {
                    return(product);
                }
            }
            return(null);
        }
示例#5
0
        // This is the entry point method for the example.检查加载项信息,是否有可试用
        public async Task SetupSubscriptionInfoAsync()
        {
            if (context == null)
            {
                context = StoreContext.GetDefault();
                // If your app is a desktop app that uses the Desktop Bridge, you
                // may need additional code to configure the StoreContext object.
                // For more info, see https://aka.ms/storecontext-for-desktop.
            }

            //检查用户是否有订阅的许可证传给userOwnsSubscription值
            userOwnsSubscription = await CheckIfUserHasSubscriptionAsync();

            if (userOwnsSubscription)
            {
                Loading.IsActive = false;
                var messageDig = new MessageDialog("您已订阅此服务!");
                //展示窗口,获取按钮是否退出  
                var result = await messageDig.ShowAsync();

                // 解锁所有加载项订阅的特性功能
                return;
            }

            //获取订阅信息.传给subscriptionStoreProduct值。
            subscriptionStoreProduct = await GetSubscriptionProductAsync();

            if (subscriptionStoreProduct == null)
            {
                Loading.IsActive = false;
                var messageDig = new MessageDialog("此订阅暂不提供!");
                //展示窗口,获取按钮是否退出  
                var result = await messageDig.ShowAsync();

                return;
            }

            //检查第一个SKU是否是试用版,并通知客户试用版可用。
            //如果试用可用,Skus数组将始终具有两个可购买的SKU,以及
            // first one is the trial. Otherwise,第一个是审判。否则,该数组将只有一个SKU。
            StoreSku sku = subscriptionStoreProduct.Skus[0];

            if (sku.SubscriptionInfo.HasTrialPeriod)
            {
                //如果存在试用
                //您可以在这里向客户显示订阅购买信息。你可以使用
                // sku.SubscriptionInfo.BillingPeriod and sku.SubscriptionInfo.BillingPeriodUnit
                //提供续约详情。
            }
            else
            {
                //不存在试用
                //您可以在这里向客户显示订阅购买信息。你可以使用
                // sku.SubscriptionInfo.BillingPeriod and sku.SubscriptionInfo.BillingPeriodUnit
                //提供续约详情。
            }

            // Prompt the customer to purchase the subscription.
            await PromptUserToPurchaseAsync();
        }
示例#6
0
        public IHttpActionResult PutStoreProduct(int id, StoreProduct storeProduct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != storeProduct.Id)
            {
                return(BadRequest());
            }

            db.Entry(storeProduct).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StoreProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult _Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StoreProduct           storeProduct = _dbContext.StoreProducts.Find(id);
            StoreProductsViewModel viewModel    = new StoreProductsViewModel();

            viewModel.Id               = storeProduct.Id;
            viewModel.BatchId          = storeProduct.BatchId;
            viewModel.BatchNumber      = storeProduct.BatchNumber;
            viewModel.CostPricePerUnit = storeProduct.CostPricePerUnit;
            viewModel.Quantity         = storeProduct.Quantity;
            viewModel.MRPPerUnit       = storeProduct.MRPPerUnit;
            viewModel.ProductEnterDate = storeProduct.ProductEnterDate;
            viewModel.ProductName      = storeProduct.Product.Name;
            viewModel.Code             = storeProduct.Product.Code;
            if (storeProduct == null)
            {
                return(HttpNotFound());
            }
            string modelString = RenderRazorViewToString("_Edit", viewModel);

            //ViewBag.BatchId = new SelectList(_dbContext.Batch, "Id", "Name", storeProduct.BatchId);
            return(Json(new { ModelString = modelString }, JsonRequestBehavior.AllowGet));
        }
示例#8
0
        public async Task <ActionResult> Add(StoreProduct model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            using (var conn = new SqlConnection(ConnString))
            {
                await conn.OpenAsync();

                using (var cmd = new SqlCommand("StoreProductsInsert", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("ItemName", SqlDbType.NVarChar, 255)).Value         = model.Name;
                    cmd.Parameters.Add(new SqlParameter("ItemDescription", SqlDbType.NVarChar, 3000)).Value = model.Description;
                    cmd.Parameters.Add(new SqlParameter("ItemColor", SqlDbType.NVarChar, 10)).Value         = model.Color;
                    cmd.Parameters.Add(new SqlParameter("ItemSize", SqlDbType.NVarChar, 10)).Value          = model.Size;
                    cmd.Parameters.Add(new SqlParameter("ItemAgeRestricted", SqlDbType.Bit)).Value          = model.AgeRestricted;

                    await cmd.ExecuteNonQueryAsync();
                }
            }

            return(RedirectToAction("Products"));
        }
示例#9
0
        public GetStoreProductResponse GetStoreProduct(Guid storeID, Guid productID)
        {
            // if need must be configured correctly
            GetStoreProductResponse response = new GetStoreProductResponse();

            try
            {
                StoreProduct     storeProduct     = new StoreProduct();
                StoreProductView storeProductView = storeProduct.ConvertToStoreProductView();

                storeProduct = _storeProductRepository.FindBy(storeID, productID);
                if (storeProduct != null)
                {
                    storeProductView = storeProduct.ConvertToStoreProductView();
                }

                response.StoreProductView = storeProductView;
            }
            catch (Exception ex)
            {
                throw;
            }

            return(response);
        }
        // Has the user purchased this collection?
        private async Task <bool> IsPurchased()
        {
            if (_Context == null)
            {
                _Context = StoreContext.GetDefault();
            }

            // Specify the kinds of add-ons to retrieve.
            var filterList = new List <string>(new[] { "Durable" });
            var idList     = new List <string>(new[] { _StoreId });

            StoreProductQueryResult queryResult = await _Context.GetStoreProductsAsync(filterList, idList);

            if (queryResult.ExtendedError != null)
            {
                // The user may be offline or there might be some other server failure.
                Debug.WriteLine($"ExtendedError: {queryResult.ExtendedError.Message}");
                return(false);
            }


            foreach (var item in queryResult.Products)
            {
                StoreProduct product = item.Value;
                return(product.IsInUserCollection);
            }

            return(false);
        }
示例#11
0
        public void InitiateDownload(StoreProduct storeProduct)
        {
            List <int> stickerIds = storeProduct.stickers.sticker_ids;
            string     baseUrl    = storeProduct.stickers.base_url;
            List <RemoteLocalMapping> downloadList = new List <RemoteLocalMapping>();

            foreach (int stickerId in stickerIds)
            {
                downloadList.Add(new RemoteLocalMapping()
                {
                    RemoteUri = baseUrl + (object)stickerId + "/256b.png",
                    LocalPath = this.GetLocalPathForStickerId256(storeProduct, stickerId)
                });
                if (ScaleFactor.GetScaleFactor() == 100)
                {
                    downloadList.Add(new RemoteLocalMapping()
                    {
                        RemoteUri = baseUrl + (object)stickerId + "/128b.png",
                        LocalPath = this.GetLocalPathForStickerId128(storeProduct, stickerId)
                    });
                }
            }
            downloadList.Add(new RemoteLocalMapping()
            {
                RemoteUri = storeProduct.base_url + "/background.png",
                LocalPath = storeProduct.id.ToString() + "background.png"
            });
            BatchDownloadManager.GetDownloadManager(storeProduct.id.ToString(), downloadList).Start();
        }
示例#12
0
    /// <summary>
    /// automatically called after one product is bought
    /// </summary>
    /// <param name="status">The purchase status: Success/Failed</param>
    /// <param name="message">Error message if status is failed</param>
    /// <param name="product">the product that was bought, use the values from shop product to update your game data</param>
    private void ProductBought(IAPOperationStatus status, string message, StoreProduct product)
    {
        purchaseInProgress = false;
        if (status == IAPOperationStatus.Success)
        {
            if (IAPManager.Instance.debug)
            {
                Debug.Log("Buy product completed: " + product.localizedTitle + " receive value: " + product.value);
                GleyEasyIAP.ScreenWriter.Write("Buy product completed: " + product.localizedTitle + " receive value: " + product.value);
            }

            //each consumable gives coins in this example
            if (product.productType == ProductType.Consumable)
            {
                coins += product.value;
            }

            //non consumable Unlock Level 1 -> unlocks level 1 so we set the corresponding bool to true
            if (product.productName == "UnlockLevel1")
            {
                //unlockLevel1 = true;
            }

            //non consumable Unlock Level 2 -> unlocks level 2 so we set the corresponding bool to true
            if (product.productName == "UnlockLevel2")
            {
                //unlockLevel2 = true;
            }

            //subscription has been bought so we set our subscription variable to true
            if (product.productName == "Subscription")
            {
                //subscription = true;
            }

            if (product.productType == ProductType.NonConsumable)
            {
                if (product.active)
                {
                    nonCOnsumableProducts.First(cond => cond.name.ToString() == product.productName).bought = true;
                }
            }
            if (product.productType == ProductType.Subscription)
            {
                if (product.active)
                {
                    subscriptions.First(cond => cond.name.ToString() == product.productName).bought = true;
                }
            }
        }
        else
        {
            //en error occurred in the buy process, log the message for more details
            if (IAPManager.Instance.debug)
            {
                Debug.Log("Buy product failed: " + message);
                GleyEasyIAP.ScreenWriter.Write("Buy product failed: " + message);
            }
        }
    }
示例#13
0
        private async void ChangeWantedAmountMethod()
        {
            if (SelectedProduct != null)
            {
                int          storeId          = Controller.Instance.StoreId;
                int          id               = SelectedProduct.ProductId;
                int          wanted           = SelectedProduct.Wanted;
                StoreProduct tempStoreProduct = new StoreProduct(storeId, id, wanted);

                // update doesnt work because of a badrequest(400), i cant fix i so we decided to just delete the old one and create a new one with the values given
                int key = Catalog <StoreProduct> .Instance.GetList.Find(x =>
                                                                        x.Store == storeId && x.Product == id).Id;

                await Catalog <StoreProduct> .Instance.Delete(key);

                if (wanted >= 1)
                {
                    await Catalog <StoreProduct> .Instance.Create(tempStoreProduct);

                    ChangeWantedAmountResponse = $"det ønskede antal for {SelectedProduct.MyProduct.Name} er blevet ændret";
                }
                if (wanted <= 0)
                {
                    ChangeWantedAmountResponse = $"Da du har ønsket {wanted} er produkt blevet fjernet";
                }



                OnPropertyChanged(nameof(ChangeWantedAmountResponse));
                OnPropertyChanged(nameof(ProductCatalog));
            }
        }
        public async Task <IActionResult> PutProduct([FromRoute] int id, [FromBody] StoreProduct storeProduct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != storeProduct.ID)
            {
                return(BadRequest());
            }

            _context.Entry(storeProduct).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Exists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#15
0
        public ActionResult ViewSellProductQty(int nStoreID, int nStoreProductID)
        {
            GlobalSession.SessionIsAlive(Session, Response);
            _oStoreProduct         = new StoreProduct();
            _oStoreProduct.StoreID = nStoreID;

            if (nStoreProductID > 0)
            {
                _oStoreProduct = _oStoreProductService.Get(nStoreID, nStoreProductID, (int)Session[GlobalSession.UserID]);
            }
            ContractorService oContractorService = new ContractorService();
            List <Contractor> oContractors       = new List <Contractor>();

            oContractors = oContractorService.GetsByContractorType(EnumContractorType.Supplier, (int)Session[GlobalSession.UserID]);

            List <ProductCategory> oProductCategorys       = new List <ProductCategory>();
            ProductCategoryService oProductCategoryService = new ProductCategoryService();

            oProductCategorys = oProductCategoryService.Gets(1, (int)Session[GlobalSession.UserID]);

            List <Product> oProducts       = new List <Product>();
            ProductService oProductService = new ProductService();

            oProducts = oProductService.Gets(1, (int)Session[GlobalSession.UserID]);

            ViewBag.ProductTypes     = _oProductTypeService.Gets(1, (int)Session[GlobalSession.UserID]);
            ViewBag.Contractors      = oContractors;
            ViewBag.Products         = oProducts;
            ViewBag.ProductCategorys = oProductCategorys;

            return(View(_oStoreProduct));
        }
        private StoreProduct MapObject(SqlDataReader oReader)
        {
            StoreProduct oStoreProduct = new StoreProduct();

            oStoreProduct.StoreProductID    = (int)oReader["StoreProductID"];
            oStoreProduct.StoreID           = (int)oReader["StoreID"];
            oStoreProduct.ProductID         = (int)oReader["ProductID"];
            oStoreProduct.ContractorID      = (int)oReader["ContractorID"];
            oStoreProduct.ProductQty        = Convert.ToDouble(oReader["ProductQty"]);
            oStoreProduct.Remarks           = oReader["Remarks"].ToString();
            oStoreProduct.ProductName       = oReader["ProductName"].ToString();
            oStoreProduct.ProductCode       = oReader["ProductCode"].ToString();
            oStoreProduct.ProductTypeID     = (int)oReader["ProductTypeID"];
            oStoreProduct.ProductTypeName   = oReader["ProductTypeName"].ToString();
            oStoreProduct.ProductTypeCode   = oReader["ProductTypeCode"].ToString();
            oStoreProduct.ProductCategoryID = (int)oReader["ProductCategoryID"];
            oStoreProduct.CategoryCode      = oReader["CategoryCode"].ToString();
            oStoreProduct.Categoryname      = oReader["Categoryname"].ToString();
            oStoreProduct.ContractorName    = oReader["ContractorName"].ToString();
            oStoreProduct.UnitPrice         = Convert.ToDouble(oReader["UnitPrice"]);
            oStoreProduct.StoreDate         = Convert.ToDateTime(oReader["LastUpdatedDateTime"]);
            oStoreProduct.StoreEntryDate    = Convert.ToDateTime(oReader["DBServerDateTime"]);

            return(oStoreProduct);
        }
示例#17
0
        private void AddToCart_Click(object sender, EventArgs e)
        {
            if (Products.SelectedItem == null)
            {
                return;
            }

            String       selected     = Products.SelectedItem.ToString();
            StoreProduct storeProduct = new StoreProduct();

            storeProduct.RefactorString(selected);

            int         ActualAmount = storeProduct.amount;
            ProductInfo temp         = new ProductInfo(ActualAmount);

            temp.ShowDialog();
            if (amount != 0)
            {
                DataTable firstTime = queries.isItFirstTime(controller.normalUser.Data.ID);
                if (firstTime.Rows.Count <= 0)
                {
                    cartObject = new CartItem(storeProduct.storeProductID, storeProduct.product.Name, storeProduct.price, storeProduct.amount, true);
                }
                else
                {
                    cartObject = new CartItem(storeProduct.storeProductID, storeProduct.product.Name, storeProduct.price, storeProduct.amount, false);
                }
                cartController.addCartItem(cartObject);
            }
            else
            {
                MessageBox.Show("failed to add items to the cart");
            }
        }
示例#18
0
        public async Task AddToBasketAsync(Guid userId, Guid productId, int quantity)
        {
            _logger.LogInformation("Updating basket for user {0}", userId);
            try
            {
                Model.ShoppingCart cart = await GetBasket(userId);

                StoreProduct product = await _productService.GetAsync(productId);

                if (product == null)
                {
                    _logger.LogWarning("Product {0} can not be added to cart for user {1} as it does not exist", productId, userId);
                    throw new ShoppingCartException($"Product {productId} does not exist");
                }
                List <ShoppingCartItem> cartItems = new List <ShoppingCartItem>(cart.Items);
                cartItems.Add(new ShoppingCartItem
                {
                    Product  = product,
                    Quantity = quantity
                });
                cart.Items = cartItems;
                await _repository.UpdateAsync(cart);

                _logger.LogInformation("Updated basket for user {0}", userId);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Unable to add product {0} to basket for user {1}", productId, userId);
                throw new ShoppingCartException("Unable to add to basket");
            }
        }
示例#19
0
        public async void GetUserCollection()
        {
            if (context == null)
            {
                context = StoreContext.GetDefault();
                // If your app is a desktop app that uses the Desktop Bridge, you
                // may need additional code to configure the StoreContext object.
                // For more info, see https://aka.ms/storecontext-for-desktop.
            }

            // Specify the kinds of add-ons to retrieve.
            string[]      productKinds = { "Durable" };
            List <String> filterList   = new List <string>(productKinds);

            workingProgressRing.IsActive = true;
            StoreProductQueryResult queryResult = await context.GetUserCollectionAsync(filterList);

            workingProgressRing.IsActive = false;

            if (queryResult.ExtendedError != null)
            {
                // The user may be offline or there might be some other server failure.
                textBlock.Text = $"ExtendedError: {queryResult.ExtendedError.Message}";
                return;
            }

            foreach (KeyValuePair <string, StoreProduct> item in queryResult.Products)
            {
                StoreProduct product = item.Value;

                // Use members of the product object to access info for the product...
            }
        }
示例#20
0
        public async Task <CommandResponse> ExecuteAsync(AddToCartCommand command, CommandResponse previousResult)
        {
            Model.ShoppingCart cart = await _repository.GetActualOrDefaultAsync(command.AuthenticatedUserId);

            StoreProduct product = (await _dispatcher.DispatchAsync(new GetStoreProductQuery {
                ProductId = command.ProductId
            })).Result;

            if (product == null)
            {
                _logger.LogWarning("Product {0} can not be added to cart for user {1} as it does not exist", command.ProductId, command.AuthenticatedUserId);
                return(CommandResponse.WithError($"Product {command.ProductId} does not exist"));
            }
            List <ShoppingCartItem> cartItems = new List <ShoppingCartItem>(cart.Items);

            cartItems.Add(new ShoppingCartItem
            {
                Product  = product,
                Quantity = command.Quantity
            });
            cart.Items = cartItems;
            await _repository.UpdateAsync(cart);

            _logger.LogInformation("Updated basket for user {0}", command.AuthenticatedUserId);
            return(CommandResponse.Ok());
        }
示例#21
0
 void NotifyDelegateDidBuyProduct(StoreProduct product, bool isSuccessful, string errorMessage)
 {
     if (DependencyLoader.DependencyCheck <IapControllerDelegate>(iapDelegate, this, gameObject, debugger))
     {
         iapDelegate.DidBuyProduct(product, isSuccessful, errorMessage);
     }
 }
示例#22
0
    private void ProductBoughtCallback(IAPOperationStatus status, string message, StoreProduct product)
    {
        if (status == IAPOperationStatus.Success)
        {
            if (product.productName == "RemoveAds")
            {
                noAds = true;
                return;
            }
            else if (product.productName == "UnlockChaos")
            {
                unlockedChaos = true;
            }
            else if (product.productName == "UnlockImpossible")
            {
                unlockedImpossible = true;
            }
            else if (product.productName == "UnlockUnfair")
            {
                unlockedUnfair = true;
            }

            GameObject.Find("Game Mode Manager").GetComponent <GameModeManager>().UpdateGameModeDisplay();
        }
    }
示例#23
0
        private async Task <StoreProduct> GetSubscriptionProductAsync()
        {
            // Load the sellable add-ons for this app and check if the trial is still
            // available for this customer. If they previously acquired a trial they won't
            // be able to get a trial again, and the StoreProduct.Skus property will
            // only contain one SKU.

            StoreProductQueryResult result =
                await context.GetAssociatedStoreProductsAsync(new string[] { "Durable" });

            if (result.ExtendedError != null)
            {
                System.Diagnostics.Debug.WriteLine("Something went wrong while getting the add-ons. " +
                                                   "ExtendedError:" + result.ExtendedError);

                return(null);
            }

            // Look for the product that represents the subscription.

            foreach (var item in result.Products)
            {
                StoreProduct product = item.Value;
                if (product.StoreId == subscriptionStoreId)
                {
                    return(product);
                }
            }

            System.Diagnostics.Debug.WriteLine("The subscription was not found.");
            return(null);
        }
示例#24
0
        private bool TrySlideToStickersPack(long productId)
        {
            this.InitPanel();
            int num = -1;
            ObservableCollection <object> items = this._stickersSlideView.Items;

            for (int index = 0; index < items.Count; ++index)
            {
                StoreProduct stickerProduct = ((SpriteListItemData)items[index]).StickerProduct;
                if (stickerProduct != null && (long)stickerProduct.id == productId)
                {
                    num = index;
                    break;
                }
            }
            if (num < 0)
            {
                return(false);
            }
            if (this._stickersSlideView.SelectedIndex != num)
            {
                this._stickersSlideView.SelectedIndex = num;
            }
            return(true);
        }
示例#25
0
        private async void AddToWantedListMethod()
        {
            int  storeId  = Controller.Instance.StoreId;
            bool isOnList = false;

            foreach (var storeProduct in Catalog <StoreProduct> .Instance.GetList)
            {
                if (storeProduct.Product == SelectedProduct.Id && storeProduct.Store == storeId)
                {
                    isOnList            = true;
                    AddToWantedResponse = $"{SelectedProduct.Name} er allerede på listen";
                }
            }

            if (!isOnList && WantedAmount > 0)
            {
                int          productId    = SelectedProduct.Id;
                int          wantedAmount = WantedAmount;
                StoreProduct spToAdd      = new StoreProduct(storeId, productId, wantedAmount);
                await Catalog <StoreProduct> .Instance.Create(spToAdd);

                AddToWantedResponse = $"{SelectedProduct.Name} er nu tilføjet til listen";
            }

            if (WantedAmount <= 0)
            {
                AddToWantedResponse = "det ønskede antal skal være over 0";
            }
            OnPropertyChanged(nameof(AddToWantedResponse));
        }
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StoreProduct           storeProduct = _dbContext.StoreProducts.Find(id);
            StoreProductsViewModel viewModel    = new StoreProductsViewModel();

            viewModel.Id               = storeProduct.Id;
            viewModel.BatchId          = storeProduct.BatchId;
            viewModel.StoreId          = storeProduct.Batch.StoreId;
            viewModel.BatchNumber      = storeProduct.BatchNumber;
            viewModel.CostPricePerUnit = storeProduct.CostPricePerUnit;
            viewModel.Quantity         = storeProduct.Quantity;
            viewModel.MRPPerUnit       = storeProduct.MRPPerUnit;
            viewModel.ProductEnterDate = storeProduct.ProductEnterDate;
            viewModel.ProductId        = storeProduct.Product.Id;
            viewModel.ProductName      = storeProduct.Product.Name;
            viewModel.Code             = storeProduct.Product.Code;
            // viewModel.SalePrice = storeProduct.SalePrice;
            if (storeProduct == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Batches = new SelectList(_dbContext.Batch, "Id", "Name", storeProduct.BatchId);
            ViewBag.Stores  = new SelectList(_dbContext.Stores, "Id", "Name", storeProduct.Batch.StoreId);
            return(View(viewModel));
        }
示例#27
0
        public GeneralResponse DeleteStoreProduct(Guid storeID, Guid productID)
        {
            GeneralResponse response = new GeneralResponse();

            StoreProduct storeProduct = new StoreProduct();

            storeProduct = _storeProductRepository.FindBy(storeID, productID);

            if (storeProduct != null)
            {
                try
                {
                    _storeProductRepository.Remove(storeProduct);
                    #region Edit UnitsInStock Of Product Entity
                    Product product = new Product();
                    product = _productRepository.FindBy(productID);
                    product.UnitsInStock += storeProduct.UnitsInStock;
                    _productRepository.Save(product);
                    #endregion
                    _uow.Commit();
                }
                catch (Exception ex)
                {
                    response.ErrorMessages.Add(ex.Message);
                }
            }

            return(response);
        }
示例#28
0
        private static void CreateVotesPacks(IEnumerable <StockItem> stockItems, IDictionary <string, string> inAppPrices = null, Action <List <VotesPack> > callback = null)
        {
            List <VotesPack> votesPackList = new List <VotesPack>();

            foreach (StockItem stockItem in stockItems.Where <StockItem>((Func <StockItem, bool>)(stockItem => stockItem.product != null)))
            {
                StoreProduct product           = stockItem.product;
                int          votes             = product.votes;
                string       merchantProductId = stockItem.merchant_product_id;
                VotesPack    votesPack         = new VotesPack()
                {
                    ProductId         = product.id,
                    MerchantProductId = merchantProductId,
                    Title             = product.title,
                    VotesCount        = votes
                };
                if (inAppPrices != null && inAppPrices.ContainsKey(merchantProductId))
                {
                    votesPack.PaymentType = AccountPaymentType.inapp;
                    votesPack.PriceStr    = inAppPrices[merchantProductId];
                }
                else
                {
                    votesPack.PaymentType = AccountPaymentType.money;
                    votesPack.PriceStr    = stockItem.price_str;
                }
                votesPackList.Add(votesPack);
            }
            if (callback == null)
            {
                return;
            }
            callback(votesPackList);
        }
    void IapControllerDelegate.DidRestoreProduct(StoreProduct product, bool isSuccessful, string errorMessage)
    {
        // Products must be initially populated (validated) before it can be restored.
        if (HasProducts())
        {
            for (int i = 0; i < products.Count; i++)
            {
                StoreProduct currentProduct = products[i];

                if (currentProduct.productName == product.productName)
                {
                    // Replace it
                    products[i] = product;

                    debugger.Log("Restored a purchase: " + product.productName, this, gameObject);
                    break;
                }
            }
        }
        else
        {
            // If it does not exist, add it
            products.Add(product);

            debugger.Log("Restored a purchase that was not validated: " + product.productName, this, gameObject);
        }

        if (RestoredProductEvent != null)
        {
            RestoredProductEvent(product, isSuccessful, errorMessage);
        }
    }
示例#30
0
        public List <Product> LoadProducts(string prodName = "")
        {
            List <Product> prods;

            if (prodName == "")
            {
                prods = (from p in db.Products
                         select p)
                        .OrderBy(p => p.Description).ToList();
            }
            else
            {
                prods = (from p in db.Products
                         where p.Description.Contains(prodName)
                         select p)
                        .OrderBy(p => p.Description).ToList();
            }

            foreach (Product prod in prods)
            {
                StoreProduct sp = (from s in db.StoreProducts
                                   where (s.StoreID == 1) && (s.ProductID == prod.ProductID)
                                   select s).SingleOrDefault();

                prod.StoreProduct = sp;
            }

            return(prods);
        }
    public StoreProduct[] ListProducts()
    {
        // Make the List an Array to prevent Mutation outside this class

        StoreProduct[] productArray = new StoreProduct[products.Count];
        for(int i=0; i<products.Count; i++)
        {
            productArray[i] = products[i];
        }
        return productArray;
    }
 public static StoreProduct StringToProduct(string productInfo)
 {
     string[] words = productInfo.Split('|');
     if(words.Length == 4)
     {
         StoreProduct product = new StoreProduct(
             words[0],
             words[1],
             words[2],
             words[3]);
         return product;
     }else{
         throw new System.FormatException("Could NOT create Product from string " + productInfo);
     }
 }
示例#33
0
        public EditProduct()
        {
            storeProductRep = new StoreProductRepository();
            storeAnimeRep = new StoreAnimeRepository();
            storeColorRep = new StoreColorRepository();

            long productID = 0;
            if (!string.IsNullOrEmpty(HttpContext.Current.Request["ProductID"]))
                productID = MyCommon.ToLong(HttpContext.Current.Request["ProductID"]);
            if (productID > 0)
            {
                _product = storeProductRep.GetProductByID(productID);
                if (_product == null)
                    HttpContext.Current.Response.Redirect("ProductList.aspx");
            }
        }
示例#34
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            decimal retailPrice = 0;
            if (!string.IsNullOrEmpty(txtRetailPrice.Text))
                decimal.TryParse(txtRetailPrice.Text, out retailPrice);
            decimal salePrice = 0;
            decimal.TryParse(txtSalePrice.Text, out salePrice);
            decimal vipPrice = 0;
            decimal.TryParse(txtVipPrice.Text, out vipPrice);

            HttpPostedFile imageFile = null;
            if (radImgNew.Checked && fupFile.PostedFile != null &&
                fupFile.PostedFile.ContentLength != 0)
                imageFile = fupFile.PostedFile;

            HttpPostedFile image2File = null;
            if (fup2.PostedFile != null && fup2.PostedFile.ContentLength != 0)
                image2File = fup2.PostedFile;

            HttpPostedFile image3File = null;
            if (fup3.PostedFile != null && fup3.PostedFile.ContentLength != 0)
                image3File = fup3.PostedFile;

            HttpPostedFile image4File = null;
            if (fup4.PostedFile != null && fup4.PostedFile.ContentLength != 0)
                image4File = fup4.PostedFile;

            List<int> colorIDs = new List<int>();
            foreach (ListItem item in chkColors.Items)
            {
                if (item.Selected)
                    colorIDs.Add(int.Parse(item.Value));
            }

            int animeID = 0;
            int.TryParse(ddlAnimes.SelectedValue, out animeID);

            if (_product == null)
                _product = new StoreProduct();
            _product.AnimeID = animeID;
            _product.ProductCode = txtCode.Text;
            _product.Name = txtName.Text;
            _product.Description = txtDescription.Text;
            _product.Title = txtShortDescription.Text;
            _product.PageName = txtUrl.Text;
            _product.IsActive = chkApproved.Checked;
            _product.IsFeatured = chkFeatured.Checked;
            if (imageFile != null)
            {
                string path = Server.MapPath("~/images/");
                imageFile.SaveAs(string.Format("{0}{1}", path, imageFile.FileName));
                _product.ImageFile = imageFile.FileName;
            }
            if (image2File != null)
                _product.ImageFile2 = image2File.FileName;
            if (image3File != null)
                _product.ImageFile3 = image3File.FileName;
            if (image4File != null)
                _product.ImageFile4 = image4File.FileName;
            if (retailPrice > 0)
                _product.RetailPrice = retailPrice;
            if (salePrice > 0)
                _product.SalePrice = salePrice;
            if (vipPrice > 0)
                _product.VIPPrice = vipPrice;

            storeProductRep.SaveProduct(_product);
        }