public static void InsertNewProductType(string name, string desc) { ProductType newProduct = ProductTypeFactory.CreateNewProductType(name, desc); db.ProductTypes.Add(newProduct); db.SaveChanges(); }
public static void Create(String productTypeName, String description) { ProductType prk = ProductTypeFactory.CreateProduct(productTypeName, description); db.ProductTypes.Add(prk); db.SaveChanges(); }
public static void InsertProductType(string ProductType, string Description) { int max = db.MsProductTypes.Max(x => x.ID); db.MsProductTypes.Add(ProductTypeFactory.initProduct(++max, ProductType, Description)); db.SaveChanges(); }
protected void Btn_SubmitProductTypeID(object sender, EventArgs e) { if (Page.IsValid) { try { int ID = Convert.ToInt32(HdnProductTypeId.Value); string Name = NameTxt.Text.ToString(); string Desc = DescTxt.Text.ToString(); ProductTypes productType = ProductTypeFactory.CreateProductType(ID, Name, Desc); ProductTypes updatedProductType = ProductTypeHandler.UpdateProductType(productType); if (productType == null) { throw new Exception(); } else { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Data Updated Succesfully" + "');", true); Response.Redirect("ViewProductType.aspx"); } } catch (Exception ex) { throw ex; } } }
public async Task Post_WhenOrderHasDuplicatedItems_ShouldAggregateAndReturnOk() { var order = new OrderRequest { OrderId = 1, Items = new List <OrderItemDTO> { new OrderItemDTO { ProductType = EnumProductType.mug, Quantity = 1 }, new OrderItemDTO { ProductType = EnumProductType.mug, Quantity = 2 }, new OrderItemDTO { ProductType = EnumProductType.mug, Quantity = 1 } } }; var json = GetJsonContent(order); var result = await httpClient.PostAsync("/api/order/", json); Assert.AreEqual(result.StatusCode, HttpStatusCode.OK); var width = await result.Content.ReadAsStringAsync(); var expectedWidth = ProductTypeFactory.Create(EnumProductType.mug).PackageWidth; Assert.AreEqual(Convert.ToDecimal(width), expectedWidth); }
public SBInventoryCategoriesController() { _factory = new CategoriesFactory(); _productTypeFactory = new ProductTypeFactory(); //================ ViewBag.ListStore = GetListStore(); }
public static void CleanUpProductTypes(ServiceClientMessageHandler handler, List <int> productTypeIds) { foreach (var id in productTypeIds) { ProductTypeFactory.DeleteProductType(handler, id); } }
public void UpdateAttributeTest10() { var attrObj = Generator.GenerateAttribute(isProperty: true); var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj); attributeFQN1.Add(createdAttr.AttributeFQN); var myPT = Generator.GenerateProductType(createdAttr, Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly)); var createdPT = ProductTypeFactory.AddProductType(ApiMsgHandler, myPT); productTypeId1.Add(createdPT.Id.Value); createdAttr.Content = Generator.GenerateAttributeLocalizedContent(); createdAttr.Validation = Generator.GenerateAttributeValidation(null, null, null, null, Generator.RandomInt(5, 10), Generator.RandomInt(1, 4)); createdAttr.AttributeMetadata = Generator.GenerateAttributeMetadataItemList(); createdAttr.AttributeMetadata.Clear(); createdAttr.AttributeMetadata.Add(Generator.GenerateAttributeMetadataItem()); var updateAttr = AttributeFactory.UpdateAttribute(ApiMsgHandler, createdAttr, createdAttr.AttributeFQN); Assert.AreEqual(createdAttr.Content.Description, updateAttr.Content.Description); Assert.AreEqual(createdAttr.Content.Name, updateAttr.Content.Name); Assert.AreEqual(createdAttr.Validation.MaxStringLength, updateAttr.Validation.MaxStringLength); Assert.AreEqual(createdAttr.Validation.MinStringLength, updateAttr.Validation.MinStringLength); Assert.AreEqual(createdAttr.AttributeMetadata.Count, updateAttr.AttributeMetadata.Count); Assert.AreEqual(createdAttr.AttributeMetadata.Last().Key, updateAttr.AttributeMetadata.First().Key); Assert.AreEqual(createdAttr.AttributeMetadata.Last().Value, updateAttr.AttributeMetadata.First().Value); }
public static void insertProductType(string name, string desc) { ProductType pt = ProductTypeFactory.insertProductType(name, desc); dbEntity.ProductTypes.Add(pt); dbEntity.SaveChanges(); }
public void validateUpdateProductType(TextBox txtProductType, TextBox txtDescription, Label lblErrorProductType, Label lblSuccess) { int ID = Convert.ToInt32(HttpContext.Current.Request.QueryString["producttypeid"]); string name = txtProductType.Text; string description = txtDescription.Text; List <ProductType> check = new ProductTypeHandler().GetSameNameUpdate(name); int flag = 0; foreach (var item in check) { if (item.ID != ID) { flag = 1; break; } } if (flag == 1) { lblErrorProductType.Visible = true; return; } ProductType newProductType = new ProductTypeFactory().CreateProduct(name, description); new ProductTypeHandler().UpdateProductType(newProductType, ID); lblSuccess.Visible = true; lblErrorProductType.Visible = false; }
public void UpdateAttributeTest11() { var attrObj = Generator.GenerateAttribute(isProperty: true); var vv1 = Generator.GenerateAttributeVocabularyValueRandom(); var vv2 = Generator.GenerateAttributeVocabularyValueRandom(); attrObj.VocabularyValues = Generator.GenerateAttributeVocabularyValueList(); attrObj.VocabularyValues.Clear(); attrObj.VocabularyValues.Add(vv1); var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj); attributeFQN1.Add(createdAttr.AttributeFQN); var myPT = Generator.GenerateProductType(createdAttr, Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly)); myPT.Properties.Last().VocabularyValues.Clear(); var createdPT = ProductTypeFactory.AddProductType(ApiMsgHandler, myPT); productTypeId1.Add(createdPT.Id.Value); createdAttr.VocabularyValues.First().Content.StringValue = vv2.Content.StringValue; createdAttr.VocabularyValues.First().Value = vv2.Value; var updateAttr = AttributeFactory.UpdateAttribute(ApiMsgHandler, createdAttr, createdAttr.AttributeFQN); Assert.AreEqual(vv2.Content.StringValue, updateAttr.VocabularyValues.First().Content.StringValue); Assert.AreEqual(vv2.Value, updateAttr.VocabularyValues.First().Value); // if vocabularyvalue is referenced by producttype, you can not update it myPT.Properties.First().VocabularyValues = Generator.GenerateAttributeVocabularyValueInProductTypeList(); myPT.Properties.First().VocabularyValues.Add(Generator.GenerateAttributeVocabularyValueInProductType(vv2.Value)); createdPT = ProductTypeFactory.AddProductType(ApiMsgHandler, myPT); productTypeId1.Add(createdPT.Id.Value); createdAttr.VocabularyValues.First().Content.StringValue = vv1.Content.StringValue; createdAttr.VocabularyValues.First().Value = vv1.Value; AttributeFactory.UpdateAttribute(ApiMsgHandler, createdAttr, createdAttr.AttributeFQN, expectedCode: HttpStatusCode.Conflict); }
protected void btnInsert_Click(object sender, EventArgs e) { bool passRequirements = true; String producttypename = txtProductTypeName.Text; ProductType pt = ProductTypeRepository.FindProductTypeByName(producttypename); if (txtProductTypeName.Text == "" || producttypename.Length < 5 || pt != null) { passRequirements = false; warningProductTypeName.Visible = true; } if (txtDescription.Text == "") { passRequirements = false; warningDescription.Visible = true; } if (passRequirements == true) { String description = txtDescription.Text; ProductType newProductType = ProductTypeFactory.CreateProductType(producttypename, description); ProductTypeRepository.Create(newProductType); Response.Redirect("Home.aspx"); } }
public void insertProductTypes(String productType, String desc) { ProductTypes p = ProductTypeFactory.createProductType(productType, desc); db.ProductTypes.Add(p); db.SaveChanges(); }
public static ProductType InsertProductType(string name, string desc) { ProductType pt = ProductTypeFactory.GetProductType(name, desc); db.ProductTypes.Add(pt); db.SaveChanges(); return(pt); }
public static Boolean insertProductType(string productTypeName, string productTypeDescription) { ProductType productType = ProductTypeFactory.CreateProductType(productTypeName, productTypeDescription); db.ProductTypes.Add(productType); db.SaveChanges(); return(true); }
public static List <OrderItem> ToOrderItems(this List <OrderItemDTO> orderItemDTOs) { var converter = new Converter <OrderItemDTO, OrderItem>( (o) => new OrderItem() { Product = ProductTypeFactory.Create(o.ProductType), Quantity = o.Quantity, }); return(orderItemDTOs.ConvertAll(converter)); }
public SBInventoryCategoriesInteController() { _factory = new InteCategoriesFactory(); _productTypeFactory = new ProductTypeFactory(); _facXero = new XeroFactory(); //================ //ViewBag.ListStore = GetListStore(); //if (Commons.isIntegrateXero) var ListAcc = new List <XeroDTO>(); ViewBag.ListAccountXero = new SelectList(ListAcc, "Code", "NameDisplayCombobox", "ReportingCodeName", 1); }
public Category() { //初始化ASP.NET内置对象 Response = System.Web.HttpContext.Current.Response; Request = System.Web.HttpContext.Current.Request; Server = System.Web.HttpContext.Current.Server; Session = System.Web.HttpContext.Current.Session; Application = System.Web.HttpContext.Current.Application; tools = ToolsFactory.CreateTools(); MyBLL = CategoryFactory.CreateCategory(); MyTBLL = ProductTypeFactory.CreateProductType(); }
public Brand() { //初始化ASP.NET内置对象 Response = System.Web.HttpContext.Current.Response; Request = System.Web.HttpContext.Current.Request; Server = System.Web.HttpContext.Current.Server; Session = System.Web.HttpContext.Current.Session; Application = System.Web.HttpContext.Current.Application; tools = ToolsFactory.CreateTools(); brand = BrandFactory.CreateBrand(); MyProductType = ProductTypeFactory.CreateProductType(); }
public void AddProductTypeTest() { var productType = new ProductType { GoodsType = "Physical", Name = "test34", MasterCatalogId = 1, ProductUsages = new List <String> { "Standard", "Configurable", "Component" }, }; var result = ProductTypeFactory.AddProductType(ApiMsgHandler, productType); }
public void UpdateAttributeTest9() { var attrObj = Generator.GenerateAttribute(isProperty: true); var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj); attributeFQN1.Add(createdAttr.AttributeFQN); var myPT = Generator.GenerateProductType(createdAttr, Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly)); var createdPT = ProductTypeFactory.AddProductType(ApiMsgHandler, myPT); productTypeId1.Add(createdPT.Id.Value); createdAttr.IsExtra = true; var updateAttr = AttributeFactory.UpdateAttribute(ApiMsgHandler, createdAttr, createdAttr.AttributeFQN, expectedCode: HttpStatusCode.OK); Assert.IsTrue((bool)updateAttr.IsExtra); createdAttr.IsProperty = false; AttributeFactory.UpdateAttribute(ApiMsgHandler, createdAttr, createdAttr.AttributeFQN, expectedCode: HttpStatusCode.BadRequest); }
public void DeleteAttributeTest1() { var attrObj = Generator.GenerateAttribute(isProperty: true); var createdAttr = AttributeFactory.AddAttribute(ApiMsgHandler, attrObj); attributeFQN1.Add(createdAttr.AttributeFQN); var myPT = Generator.GenerateProductType(createdAttr, Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly)); var createdPT = ProductTypeFactory.AddProductType(ApiMsgHandler, myPT); productTypeId1.Add(createdPT.Id.Value); var myProduct = Generator.GenerateProduct(createdPT); var createdProduct = ProductFactory.AddProduct(ApiMsgHandler, myProduct); productCode1.Add(createdProduct.ProductCode); AttributeFactory.DeleteAttribute(ApiMsgHandler, createdAttr.AttributeFQN, expectedCode: HttpStatusCode.Conflict); }
public ProductType GetProductTypeById(int id) { try { var db = dbClient.GetDatabase(database); var collection = db.GetCollection <BsonDocument>("ProductType"); var filter = Builders <BsonDocument> .Filter.Eq("ProductTypeId", id); var document = collection.Find(filter).FirstOrDefault(); ProductType productType = ProductTypeFactory.Create(document); return(productType); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } }
public SCMPurchasing() { //初始化ASP.NET内置对象 Response = System.Web.HttpContext.Current.Response; Request = System.Web.HttpContext.Current.Request; Server = System.Web.HttpContext.Current.Server; Session = System.Web.HttpContext.Current.Session; Application = System.Web.HttpContext.Current.Application; tools = ToolsFactory.CreateTools(); DBHelper = SQLHelperFactory.CreateSQLHelper(); depot = new SCMDepot(); supplier = new SCMSupplier(); PROBLL = ProductFactory.CreateProduct(); PROTYPEBLL = ProductTypeFactory.CreateProductType(); BRANDBLL = BrandFactory.CreateBrand(); }
public void validateInsert(TextBox txtProductType, TextBox txtDescription, Label lblErrorProductType) { string name = txtProductType.Text; string description = txtDescription.Text; bool check = new ProductTypeHandler().GetSameNameInsert(name); if (check == true) { lblErrorProductType.Text = "Must be unique"; return; } ProductType newProductType = new ProductTypeFactory().CreateProduct(name, description); new ProductTypeHandler().InsertProductType(newProductType); lblErrorProductType.Text = ""; txtProductType.Text = ""; txtDescription.Text = ""; }
public void DeleteCategoryTest3() { var cateObj = Generator.GenerateCategory(Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly)); var cate4 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj); var myPT = Generator.GenerateBasicProductType(Generator.RandomString(10, Generator.RandomCharacterGroup.AlphaOnly)); var createdPT = ProductTypeFactory.AddProductType(ApiMsgHandler, myPT); productTypeIds.Add(createdPT.Id.Value); var product = Generator.GenerateProduct(createdPT); var createdProduct = ProductFactory.AddProduct(ApiMsgHandler, product); productCode1.Add(createdProduct.ProductCode); var proInfo = Generator.GenerateProductInCatalogInfo(TestBaseTenant.MasterCatalogs.First().Catalogs.First().Id, cate4.Id, true); ProductFactory.AddProductInCatalog(ApiMsgHandler, proInfo, createdProduct.ProductCode); CategoryFactory.DeleteCategoryById(ApiMsgHandler, cate4.Id.Value, false, expectedCode: HttpStatusCode.Conflict); CategoryFactory.DeleteCategoryById(ApiMsgHandler, cate4.Id.Value, true, expectedCode: HttpStatusCode.NoContent); ProductFactory.GetProduct(ApiMsgHandler, product.ProductCode); }
public void GetListProductType() { ListProductType = new List <SelectListItem>(); ProductTypeFactory ProTypeFactory = new ProductTypeFactory(); var listPT = ProTypeFactory.GetListProductType(); foreach (var item in listPT) { if (item.Name.ToLower().Equals("promotion") || item.Name.ToLower().Equals("discount")) { continue; } ListProductType.Add(new SelectListItem { Text = item.Name, Value = item.ID }); } }
public ProductType GetProductTypeById(int id) { MySqlConnection conn = Connect(); try { conn.Open(); string sql = "SELECT * FROM productType WHERE ProductTypeId = " + id; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader rdr = cmd.ExecuteReader(); ProductType productType = ProductTypeFactory.Create(rdr); return(productType); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } finally { conn.Close(); } }
public static Product Create(BsonDocument row, int startValue = 0) { // Removes the _id row.RemoveAt(startValue + 0); Product product = new Product() { ProductId = Int32.Parse(row.GetElement(startValue + 0).Value.ToString()), ProductTypeId = Int32.Parse(row.GetElement(startValue + 1).Value.ToString()), CompanyId = Int32.Parse(row.GetElement(startValue + 2).Value.ToString()), ManagerId = row.GetElement(startValue + 3).Value.ToString(), AdministratorId = row.GetElement(startValue + 4).Value.ToString(), Product_Interval = Int32.Parse(row.GetElement(startValue + 5).Value.ToString()), AdjustedId = row.GetElement(startValue + 6).Value.ToString(), Product_Comment = row.GetElement(startValue + 7).Value.ToString(), Product_Country = row.GetElement(startValue + 8).Value.ToString(), Currency = row.GetElement(startValue + 9).Value.ToString(), Product_Type = row.GetElement(startValue + 10).Value.ToString(), Product_DescriptionString = row.GetElement(startValue + 11).Value.ToString(), Product_EndDate = Convert.ToDateTime(row.GetElement(startValue + 12).Value.ToString()), Product_ExternalReference = row.GetElement(startValue + 13).Value.ToString(), Product_Price = row.GetElement(startValue + 14).Value.ToDecimal(), Product_Interests = row.GetElement(startValue + 15).Value.ToString(), Product_Category = row.GetElement(startValue + 16).Value.ToString(), Product_CommissionPrice = row.GetElement(startValue + 17).Value.ToDecimal(), Product_SupplierId = row.GetElement(startValue + 18).Value.ToString(), Product_Rating = row.GetElement(startValue + 19).Value.ToDecimal(), Product_Key = row.GetElement(startValue + 20).Value.ToString(), Product_Max = row.GetElement(startValue + 21).Value.ToString(), Product_Name = row.GetElement(startValue + 22).Value.ToString(), Product_Price2 = row.GetElement(startValue + 23).Value.ToDecimal(), Product_Parameters = row.GetElement(startValue + 24).Value.ToString(), Product_NoticeLevel = Int32.Parse(row.GetElement(startValue + 25).Value.ToString()), Product_Premium = row.GetElement(startValue + 26).Value.ToString(), Product_Product = row.GetElement(startValue + 27).Value.ToString(), Product_Version = row.GetElement(startValue + 28).Value.ToString(), Product_Level = row.GetElement(startValue + 29).Value.ToDecimal(), Product_ApprovedDate = Convert.ToDateTime(row.GetElement(startValue + 30).Value.ToString()), ResellerId = row.GetElement(startValue + 31).Value.ToString(), Product_Retention = row.GetElement(startValue + 32).Value.ToDecimal(), Product_Rule1 = row.GetElement(startValue + 33).Value.ToDecimal(), Product_Rule2 = row.GetElement(startValue + 34).Value.ToDecimal(), Product_Rule3 = row.GetElement(startValue + 35).Value.ToDecimal(), Product_Method = row.GetElement(startValue + 36).Value.ToString(), Product_StartDate = Convert.ToDateTime(row.GetElement(startValue + 37).Value.ToString()), Product_Status = Int32.Parse(row.GetElement(startValue + 38).Value.ToString()), Product_StatusString = row[startValue + 39].ToString(), Product_PhoneNo = row.GetElement(startValue + 40).Value.ToString(), Product_URL = row.GetElement(startValue + 41).Value.ToString(), ProductType = row.GetElement(startValue + 42).Value.ToString(), }; //should be put at last index above +1. int currCursor = 43; BsonDocument document; while (currCursor < row.ElementCount) { switch (row.GetElement(currCursor).Name) { case "Company_object": document = new BsonDocument(row.GetElement(currCursor).Value[0].AsBsonDocument); Company company = CompanyFactory.Create(document); product.companyObject = company; currCursor++; break; case "ProductType_object": document = new BsonDocument(row.GetElement(currCursor).Value[0].AsBsonDocument); ProductType productType = ProductTypeFactory.Create(document); product.productTypeObject = productType; currCursor++; break; default: currCursor = row.ElementCount; break; } } return(product); }
public static Product Create(MySqlDataReader row, int startValue = 0) { //row.Read(); Product product = new Product() { ProductId = (int)row[startValue + 0], ProductTypeId = (int)row[startValue + 1], CompanyId = (int)row[startValue + 2], ManagerId = row[startValue + 3].ToString(), AdministratorId = row[startValue + 4].ToString(), Product_Interval = (int)row[startValue + 5], AdjustedId = row[startValue + 6].ToString(), Product_Comment = row[startValue + 7].ToString(), Product_Country = row[startValue + 8].ToString(), Currency = row[startValue + 9].ToString(), Product_Type = row[startValue + 10].ToString(), Product_DescriptionString = row[startValue + 11].ToString(), Product_EndDate = (DateTime)row[startValue + 12], Product_ExternalReference = row[startValue + 13].ToString(), Product_Price = Convert.ToDecimal(row[startValue + 14]), Product_Interests = row[startValue + 15].ToString(), Product_Category = row[startValue + 16].ToString(), Product_CommissionPrice = Convert.ToDecimal(row[startValue + 17].ToString()), Product_SupplierId = row[startValue + 18].ToString(), Product_Rating = Convert.ToDecimal(row[startValue + 19].ToString()), Product_Key = row[startValue + 20].ToString(), Product_Max = row[startValue + 21].ToString(), Product_Name = row[startValue + 22].ToString(), Product_Price2 = Convert.ToDecimal(row[startValue + 23].ToString()), Product_Parameters = row[startValue + 24].ToString(), Product_NoticeLevel = (int)row[startValue + 25], Product_Premium = row[startValue + 26].ToString(), Product_Product = row[startValue + 27].ToString(), Product_Version = row[startValue + 28].ToString(), Product_Level = Convert.ToDecimal(row[startValue + 29].ToString()), Product_ApprovedDate = (DateTime)row[startValue + 30], ResellerId = row[startValue + 31].ToString(), Product_Retention = (decimal)row[startValue + 32], Product_Rule1 = Convert.ToDecimal(row[startValue + 33].ToString()), Product_Rule2 = Convert.ToDecimal(row[startValue + 34].ToString()), Product_Rule3 = Convert.ToDecimal(row[startValue + 35].ToString()), Product_Method = row[startValue + 36].ToString(), Product_StartDate = (DateTime)row[startValue + 37], Product_Status = (int)row[startValue + 38], Product_StatusString = row[startValue + 39].ToString(), Product_PhoneNo = row[startValue + 40].ToString(), Product_URL = row[startValue + 41].ToString(), ProductType = row[startValue + 42].ToString() }; //should be put at last index above +1. int currCursor = 43; while (currCursor < row.FieldCount) { switch (row.GetName(currCursor)) { case "CompanyId": // Add company column count to cursor Company company = CompanyFactory.Create(row, currCursor); currCursor += 7; product.companyObject = company; break; case "ProductTypeId": // add productType column count to cursor ProductType typ = ProductTypeFactory.Create(row, currCursor); currCursor += 6; product.productTypeObject = typ; break; default: currCursor = row.FieldCount; break; } } return(product); }