protected void btnSure_Click(object sender, EventArgs e) { ProductObject dep = new ProductObject(); WebFormHelper.GetDataFromForm(this, dep); if (dep.Id < 0) { dep.Content=System.Web.HttpContext.Current.Server.HtmlEncode(dep.Content); if (SimpleOrmOperator.Create(dep)) { WebTools.Alert("添加成功!"); } else { WebTools.Alert("添加失败!"); } } else { if (SimpleOrmOperator.Update(dep)) { WebTools.Alert("修改成功!"); } else { WebTools.Alert("修改失败!"); } } }
protected void btnSure_Click(object sender, EventArgs e) { ProductObject dep = new ProductObject(); WebFormHelper.GetDataFromForm(this, dep); if (dep.Id < 0) { dep.Content = System.Web.HttpContext.Current.Server.HtmlEncode(dep.Content); if (SimpleOrmOperator.Create(dep)) { WebTools.Alert("添加成功!"); } else { WebTools.Alert("添加失败!"); } } else { if (SimpleOrmOperator.Update(dep)) { WebTools.Alert("修改成功!"); } else { WebTools.Alert("修改失败!"); } } }
private void FillValues(ProductObject proObj) { proObj.name = TextBox_ProductName.Text; proObj.artNr = TextBox1_ArticleNumber.Text; proObj.brandName = TextBox_Brand.Text; proObj.category = TextBox_Category.Text; proObj.description = help.StringToSql(TextBox_Description.Text); proObj.imgURL = Label_ImgUrl.Text; proObj.quantity = int.Parse(TextBox_Quantity.Text); proObj.priceB2B = int.Parse(TextBox_B2B.Text); proObj.priceB2C = int.Parse(TextBox_B2C.Text); if (!string.IsNullOrWhiteSpace(TextBox_Attribute1_Name.Text) && !string.IsNullOrWhiteSpace(TextBox_Attribute1_Value.Text)) { attributes.Add(TextBox_Attribute1_Name.Text + " " + TextBox_Attribute1_Value.Text); } if (!string.IsNullOrWhiteSpace(TextBox_Attribute2_Name.Text) && !string.IsNullOrWhiteSpace(TextBox_Attribute2_Value.Text)) { attributes.Add(TextBox_Attribute2_Name.Text + " " + TextBox_Attribute2_Value.Text); } if (!string.IsNullOrWhiteSpace(TextBox_Attribute3_Name.Text) && !string.IsNullOrWhiteSpace(TextBox_Attribute3_Value.Text)) { attributes.Add(TextBox_Attribute3_Name.Text + " " + TextBox_Attribute3_Value.Text); } if (!string.IsNullOrWhiteSpace(TextBox_Attribute4_Name.Text) && !string.IsNullOrWhiteSpace(TextBox_Attribute4_Value.Text)) { attributes.Add(TextBox_Attribute4_Name.Text + " " + TextBox_Attribute4_Value.Text); } }
public void Grab() { if(GameController.instance.FreeItemSlotCount >= GameController.instance.MaxSlotCount) { Debug.Log("Inventory is full"); return; } // new Vector2(rigBody2D.transform.forward.x, rigBody2D.transform.forward.y) + Vector2.up RaycastHit2D hit = Physics2D.CircleCast(rigBody2D.position, 2.0f, Vector2.zero + new Vector2(boxCol.bounds.center.x ,boxCol.bounds.center.y), 1.0f, grabbedItemMask); //Physics2D.BoxCastAll(Vector2.zero, boxCol.size * 1.6f, 0.0f, rigBody2D.transform.forward, 0.0f, grabbedItemMask); //Physics2D.BoxCastAll(rigBody2D.position, boxCol.size, 0.0f, Vector2.zero, 0.0f, grabbedItemMask); if(hit) { grabbedItem = hit.transform.gameObject.GetComponent<ProductObject>(); ProductObject grabbedItemProductObject = grabbedItem; if(grabbedItemProductObject == null) return; if(grabbedItemProductObject.Data == null) return; // Update Inventory GameController.instance.UpdateInventory(grabbedItemProductObject); // Play Animation grabMode = true; animator.SetBool("Grab", grabMode); } }
public void CheckDifferentid() { ProductObject product = new ProductObject(ProductType.good); ProductObject product2 = new ProductObject(ProductType.good); Assert.AreNotEqual(product.Id, product2.Id); }
protected void Page_Load(object sender, EventArgs e) { if (Session["Admin"] == null) //Kontrollerar om det finns en Admin session. { Response.Redirect("~/Admin/index.aspx"); //Om inte gå tillbaka till inloggning. } try { ID = int.Parse(Request.QueryString["id"]); } catch { ID = -1; } if (ID > 0) { proObj = product.GetMainProduct(ID); proObj.productID = ID; RemakePage(); makeSub = true; } else { makeSub = false; TextBox_B2B.TextMode = TextBoxMode.Number; TextBox_B2C.TextMode = TextBoxMode.Number; } }
private GenericValidator ValidateProduct(ProductObject product) { var gVal = new GenericValidator(); try { if (product.ProductId < 1) { gVal.Code = -1; gVal.Error = "Please select a Product."; return(gVal); } if (string.IsNullOrEmpty(product.Code)) { gVal.Code = -1; gVal.Error = "Please select Product Code."; return(gVal); } gVal.Code = 5; return(gVal); } catch (Exception) { gVal.Code = -1; gVal.Error = "Product Validation failed. Please provide all required fields and try again."; return(gVal); } }
public void CalculateItemLevel(ProductObject item) { for (var i = 0; i < item.Experience.Count; i++) { if (item.Experience[i] == 0) { continue; } if (item.Experience[i] == LevelCaps[LevelCaps.Count - 1].experience) { item.Level[i] = LevelCaps[LevelCaps.Count - 1].level; return; } for (var k = 0; k < LevelCaps.Count; k++) { if (item.Experience[i] >= LevelCaps[k].experience && item.Experience[i] < LevelCaps[k + 1].experience) { item.Level[i] = LevelCaps[k].level; break; } } } }
public void GrabItem(ProductObject grabbedItemProductObject) { if(GameController.instance.FreeItemSlotCount >= GameController.instance.MaxSlotCount) { GameController.instance.InvetoryIsFull(); return; } grabbedItem = grabbedItemProductObject; if(grabbedItemProductObject == null) return; if(grabbedItemProductObject.Data == null) return; //Debug.Log(grabbedItemProductObject.Data.QID); // Update Inventory GameController.instance.UpdateInventory(grabbedItemProductObject); // Play Animation grabMode = true; animator.SetBool("Grab", grabMode); }
public async Task <ActionResult> GetAsync(int id) { ProductObject response = new ProductObject(); try { //response.EnsureSuccessStatusCode(); //string responseBody = await response.Content.ReadAsStringAsync(); //Above three lines can be replaced with new helper method below string getProductURL = baseURL + id + exclude; string responseBody = await client.GetStringAsync(getProductURL); ProductResponseData productResponseData = JsonConvert.DeserializeObject <ProductResponseData>(responseBody); response.id = id; response.name = productResponseData.product.item.product_description.title; response.current_price = getCurrentPrice(id); Console.WriteLine(responseBody); } catch (HttpRequestException e) { if (e is HttpRequestException) { Console.WriteLine("\n HTTP get Product Response Error"); Console.WriteLine("Message :{0} ", e.Message); } } return(Ok(response)); }
public long AddProduct(ProductObject product) { try { if (product == null) { return -2; } var productEntity = ModelMapper.Map<ProductObject, Product>(product); if (productEntity == null || string.IsNullOrEmpty(productEntity.Name)) { return -2; } using (var db = new ImportPermitEntities()) { if (db.Products.Count(m => m.Code.ToLower() == product.Code.ToLower() && m.Name.ToLower() == product.Name.ToLower()) >0) { return -3; } var returnStatus = db.Products.Add(productEntity); db.SaveChanges(); var requirements = new List<ProductDocumentRequirementObject>(); if (product.ProductDocumentRequirementObjects != null) { requirements = product.ProductDocumentRequirementObjects.ToList(); } if (requirements.Any()) { requirements.ToList().ForEach(k => { if (db.ProductDocumentRequirements.Count(m => m.ProductId == product.ProductId && m.DocumentTypeId == k.DocumentTypeId) < 1) { k.ProductId = returnStatus.ProductId; var productReqEntity = ModelMapper.Map<ProductDocumentRequirementObject, ProductDocumentRequirement>(k); if (productReqEntity != null && productReqEntity.DocumentTypeId > 0 && productReqEntity.ProductId > 0) { db.ProductDocumentRequirements.Add(productReqEntity); db.SaveChanges(); } } }); } return returnStatus.ProductId; } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return 0; } }
public int GetItemCurrentExperienceCap(ProductObject item, ItemQuality quality) { if (IsMaxLevel(item, quality)) { return(0); } return(LevelCaps[item.Level[(int)quality]].experience); }
private static CategoryMenuViewModel createNewCategory(ProductObject product) { var c = new CategoryMenuViewModel { Category = product.Category }; c.Products.Add(product); return(c); }
public ActionResult ShowCase(IFormCollection collection) { _showcaseOption.LoadPostData(collection); ViewBag.DemoOptions = _showcaseOption; ViewBag.Countries = FullCountry.GetCountries(); ViewBag.Products = ProductObject.GetProductObjects(); ViewBag.Colors = ColorObject.GetColorObjects(); Theme.SetCurrentTheme(HttpContext, Themes.CleanLight); return(View(model)); }
public static ProductObject GetProduct(IWebDriver browser) { ProductPage page = new ProductPage(browser); ProductObject product = new ProductObject(); product = page.FillProductInformation(); return(product); }
public int GetItemNextLevel(ProductObject item, ItemQuality quality) { var level = item.Level[(int)quality]; if (level == LevelCaps.Count) { return(level); } return(level + 1); }
public ProductObject GetProductInformationOnCart(int positionOnCart) { ProductObject product = new ProductObject(); product.Id = GetId(positionOnCart); product.Name = GetName(positionOnCart); product.Price = GetPrice(positionOnCart); return(product); }
public long UpdateProduct(ProductObject product, List <ProductDocumentRequirementObject> newRequirements) { try { return(_productManager.UpdateProduct(product, newRequirements)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public async void SetEquipmentData(ProductObject product, ItemQuality quality = ItemQuality.Common) { var sprite = await AssetsController.LoadAsset <Sprite>(product?.IconRef); var active = (bool)sprite; SetEquipmentIcon(sprite, active); SetQualityIcon(quality, active); plusIcon.enabled = !active; itemTypeImage.enabled = !active; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.Params["id"] != null) { ProductObject entity = SimpleOrmOperator.Query <ProductObject>(Convert.ToInt32(Request.Params["id"])); WebFormHelper.SetDataToForm(this, entity); this.txtContent.Text = System.Web.HttpContext.Current.Server.HtmlDecode(entity.Content); } } }
public long AddProduct(ProductObject product) { try { return(_productManager.AddProduct(product)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public static ProductViewModel Create(ProductObject o) { var v = new ProductViewModel { Id = o.Id, Name = o.Name, Description = o.Description, Category = o.Category, BiddingEndDate = timeLeft(o.BiddingEndDate) }; return(v); }
public ProductObject FillProductInformation() { ProductObject product = new ProductObject(); product.Id = GetId(); product.Name = GetName(); product.Price = GetPrice(); return(product); }
/// <summary> /// Adds a new receipt line to the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddButton_Click(object sender, RoutedEventArgs e) { try { if (receiptIdInput.Text.Equals("") || productIdInput.Text.Equals("") || quantityInput.Text.Equals("")) { MessageBox.Show("Please input all text boxes."); receiptIdInput.Focus(); return; } else if ((!Regex.IsMatch(receiptIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(productIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(quantityInput.Text, "^[0-9]*$"))) { MessageBox.Show("Please input only numerical characters into all text boxes."); receiptIdInput.Focus(); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } ReceiptLineObject receiptLine; ReceiptObject receipt = businessLogicLayer.CheckReceiptsByID(int.Parse(receiptIdInput.Text)); ProductObject product = businessLogicLayer.CheckProductsByID(int.Parse(productIdInput.Text)); try { if (!int.Parse(receiptIdInput.Text).Equals(receipt.receipt_id)) { MessageBox.Show("The Receipt ID provided does not exist."); receiptIdInput.Focus(); return; } else if (!int.Parse(productIdInput.Text).Equals(product.product_id)) { MessageBox.Show("The Product ID provided does not exist."); productIdInput.Focus(); return; } else { receiptLine = businessLogicLayer.InsertNewReceiptLine(int.Parse(receiptIdInput.Text), int.Parse(productIdInput.Text), int.Parse(quantityInput.Text)); MessageBox.Show("The provided Receipt Line has been added to the system."); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["Admin"] == null) //Kontrollerar om det finns en Admin session. { Response.Redirect("~/Admin/index.aspx"); //Om inte gå tillbaka till inloggning. } ProductID = int.Parse(Request.QueryString["id"]); id = ProductID; proObc = product.GetProduct(ProductID); proObc.productID = ProductID; LoadValues(ProductID); FillDroppDowns(); }
/// <summary> /// Adds a new Product to the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddButton_Click(object sender, RoutedEventArgs e) { try { if (accountIdInput.Text.Equals("") || titleInput.Text.Equals("") || skuInput.Text.Equals("")) { MessageBox.Show("Please input all text boxes."); accountIdInput.Focus(); return; } else if (!Regex.IsMatch(accountIdInput.Text, "^[0-9]*$")) { MessageBox.Show("Please input only numerical characters into the Account ID text box."); accountIdInput.Focus(); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } ProductObject product = businessLogicLayer.CheckProductsByIDAndSku(int.Parse(accountIdInput.Text), skuInput.Text.ToLower()); AccountObject account = businessLogicLayer.CheckAccountsByID(int.Parse(accountIdInput.Text)); try { if (!int.Parse(accountIdInput.Text).Equals(account.account_id)) { MessageBox.Show("The Account ID provided does not exist."); accountIdInput.Focus(); return; } else if (int.Parse(accountIdInput.Text).Equals(product.account_id) && skuInput.Text.ToLower().Equals(product.sku)) { MessageBox.Show("The Account provided already has a SKU with that name."); accountIdInput.Focus(); return; } else { product = businessLogicLayer.InsertNewProduct(int.Parse(accountIdInput.Text), titleInput.Text.ToLower(), skuInput.Text.ToLower()); MessageBox.Show(titleInput.Text + " has been added to the system."); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } }
public ActionResult Put(int id, [FromBody] ProductObject product) { if (id != product.id) { return(BadRequest("PUT id is different from json body productid")); } //ProductObject product = JsonConvert.DeserializeObject<ProductObject>(value); DatastoreDb db = DatastoreDb.Create(projectId, "ProductNamespace", datastoreClient); string name = product.id + ""; double price = product.current_price.value; string currency_code = product.current_price.currency_code; KeyFactory keyFactory = db.CreateKeyFactory(kind); Key key = keyFactory.CreateKey(name); using (DatastoreTransaction transaction = db.BeginTransaction()) { Entity currentProduct = transaction.Lookup(key); transaction.Commit(); Value productid; if (currentProduct == null || !currentProduct.Properties.TryGetValue("productid", out productid)) { return(NotFound("Productid:" + name + " does not exist")); } } var task = new Entity { Key = key, ["productid"] = name, ["price"] = price, ["currency_code"] = currency_code }; try { upsert(db, task); } catch (Exception e) { if (Debugger.IsAttached) { return(Content("Productid:" + name + " might not be updated.\n" + e.StackTrace)); } else { return(BadRequest("Productid:" + name + " might not be updated.\n")); } } return(Ok("Productid:" + name + " is updated")); }
public ActionResult AddProduct(ProductObject product) { var gVal = new GenericValidator(); try { //if (!ModelState.IsValid) //{ // gVal.Code = -1; // gVal.Error = "Plese provide all required fields and try again."; // return Json(gVal, JsonRequestBehavior.AllowGet); //} var importerInfo = GetLoggedOnUserInfo(); if (importerInfo.Id < 1) { gVal.Error = "Your session has timed out"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var validationResult = ValidateProduct(product); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var appStatus = new ProductServices().AddProduct(product); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "Product upload failed. Please try again." : "The Product Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "Product was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "Product processing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
private static void AddProduct(ProductObject obj) { objs.Add(new DoubleGuid { First = obj.ProductId, Second = obj.EditionId }, new ProductEdition { EditionId = obj.EditionId, EditionName = obj.EditionName, Product = new Models.ProductObject { ProductName = obj.ProductName + "TODO: FIX DB ENGINE FOR THIS", ProductId = obj.ProductId, DownloadUrl = obj.DownloadUrl } }); }
/// <summary> /// Deletes a product from the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteButton_Click(object sender, RoutedEventArgs e) { try { if (accountIdInput.Text.Equals("") || titleInput.Text.Equals("") || skuInput.Text.Equals("")) { MessageBox.Show("Please input all text boxes."); accountIdInput.Focus(); return; } else if (!Regex.IsMatch(accountIdInput.Text, "^[0-9]*$")) { MessageBox.Show("Please input only numerical characters into the Account ID text box."); accountIdInput.Focus(); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } ProductObject product = businessLogicLayer.CheckProductsAll(int.Parse(accountIdInput.Text), titleInput.Text.ToLower(), skuInput.Text.ToLower()); try { if (!(int.Parse(accountIdInput.Text).Equals(product.account_id) && titleInput.Text.ToLower().Equals(product.title) && skuInput.Text.ToLower().Equals(product.sku))) { MessageBox.Show("The product provided does not exist."); accountIdInput.Focus(); return; } else { product = businessLogicLayer.DeleteCurrentProduct(int.Parse(accountIdInput.Text), titleInput.Text.ToLower(), skuInput.Text.ToLower()); MessageBox.Show(titleInput.Text + " has been deleted from the system."); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } }
public void test_method_2() { using (ISession unitTestSession = SampleDataTestContext.OpenSession()) { Product product = new Product { Name = "P 1", ProductId = 1, store = 1 }; unitTestSession.Save(product); unitTestSession.Flush(); ProductObject productObject = new ProductObject(unitTestSession); var productList = productObject.ReadAll(); Assert.AreEqual("P 1", productList[0].Name); } }
/// <summary> /// Add new Stock to the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddButton_Click(object sender, RoutedEventArgs e) { try { if (accountIdInput.Text.Equals("") || productIdInput.Text.Equals("") || warehouseIdInput.Text.Equals("") || quantityInput.Text.Equals("")) { MessageBox.Show("Please input all text boxes."); accountIdInput.Focus(); return; } else if ((!Regex.IsMatch(accountIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(productIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(warehouseIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(quantityInput.Text, "^[0-9]*$"))) { MessageBox.Show("Please input only numerical characters into all text boxes."); accountIdInput.Focus(); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } StockObject stock; AccountObject account = businessLogicLayer.CheckAccountsByID(int.Parse(accountIdInput.Text)); ProductObject product = businessLogicLayer.CheckProductsByID(int.Parse(productIdInput.Text)); WarehouseObject warehouse = businessLogicLayer.CheckWarehousesByID(int.Parse(warehouseIdInput.Text)); LocationObject location = businessLogicLayer.FindFreeLocation(int.Parse(warehouseIdInput.Text)); int stockLocation = location.location_id; try { if (!int.Parse(accountIdInput.Text).Equals(account.account_id)) { MessageBox.Show("The Account ID provided does not exist."); accountIdInput.Focus(); return; } else if (!int.Parse(productIdInput.Text).Equals(product.product_id)) { MessageBox.Show("The product ID provided does not exist."); productIdInput.Focus(); return; } else if (!int.Parse(warehouseIdInput.Text).Equals(warehouse.warehouse_id)) { MessageBox.Show("The Warehouse ID provided does not exist."); warehouseIdInput.Focus(); return; } else if (stockLocation.Equals(0)) { MessageBox.Show("There are no more locations free in warehouse: " + warehouseIdInput.Text); warehouseIdInput.Focus(); return; } else { stock = businessLogicLayer.InsertNewStock(int.Parse(accountIdInput.Text), int.Parse(productIdInput.Text), int.Parse(warehouseIdInput.Text), stockLocation, int.Parse(quantityInput.Text)); location = businessLogicLayer.MarkLocationAllocated(stockLocation); MessageBox.Show("The Stock provided has been added to the system. \n\nA location has been found for the Stock and is now set as allocated. \n\nThe Stock (Pallet) is now ready to be put away, please see the location code as to where."); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } }
public void GrappedItemCollected() { // Deaktiveren und Referenz entziehen if(grabbedItem != null) { grabbedItem.gameObject.SetActive(false); grabbedItem = null; } grabMode = false; animator.SetBool("Grab", grabMode); if (GameController.instance.FreeItemSlotCount >= GameController.instance.MaxSlotCount) { GameController.instance.InvetoryIsFull(); } }
public void UpdateInventory(ProductObject newProduct = null) { // Update ItemStates if(newProduct != null) { inventory.Add(newProduct.Data); for (int i = 0; i < itemsToCollect.Count; i++) { if(newProduct.Data.QID == itemsToCollect[i].QID) { itemsToCollect[i].isCollect = true; } } } // Refresh UI UIManager.instance.checklist.UpdateList(itemsToCollect.ToArray()); UIManager.instance.inventoryList.UpdateList(inventory.ToArray()); UIManager.instance.cheatInventoryList.UpdateList(GameController.instance.itemsToCollect.ToArray()); }
[TestMethod] public void CreateTest() { o = ProductObjectFactory.Create(id, name, description, category, biddingEndDate); validateResults(id, name, description, category, biddingEndDate); }