public ProductSubcategoryCollection GetAllProductSubcategoryDynamicCollection(string whereExpression, string orderBy) { IDBManager dbm = new DBManager(); ProductSubcategoryCollection cols = new ProductSubcategoryCollection(); try { dbm.CreateParameters(2); dbm.AddParameters(0, "@WhereCondition", whereExpression); dbm.AddParameters(1, "@OrderByExpression", orderBy); IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectProductSubcategoriesDynamic"); while (reader.Read()) { ProductSubcategory productSubcategory = new ProductSubcategory(); productSubcategory.ProductSubcategoryID = Int32.Parse(reader["ProductSubcategoryID"].ToString()); productSubcategory.ProductCategoryID = Int32.Parse(reader["ProductCategoryID"].ToString()); productSubcategory.Name = reader["Name"].ToString(); productSubcategory.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); cols.Add(productSubcategory); } } catch (Exception ex) { log.Write(ex.Message, "GetAllProductSubcategoryDynamicCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
public int AddProductSubcategory(ProductSubcategory productSubcategory) { IDBManager dbm = new DBManager(); int id = 0; try { dbm.CreateParameters(4); dbm.AddParameters(0, "@ProductCategoryID", productSubcategory.ProductCategoryID); dbm.AddParameters(1, "@Name", productSubcategory.Name); dbm.AddParameters(2, "@ModifiedDate", DateTime.Now); dbm.AddParameters(3, "@ProductSubcategoryID", productSubcategory.ProductSubcategoryID); dbm.Parameters[3].Direction = ParameterDirection.Output; dbm.ExecuteNonQuery(CommandType.StoredProcedure, "InsertProductSubcategory"); id = Int32.Parse(dbm.Parameters[3].Value.ToString()); } catch (Exception ex) { log.Write(ex.Message, "AddProductSubcategory"); throw (ex); } finally { dbm.Dispose(); } return(id); }
public bool UpdateProductSubcategory(ProductSubcategory productSubcategory) { IDBManager dbm = new DBManager(); try { dbm.CreateParameters(4); dbm.AddParameters(0, "@ProductSubcategoryID", productSubcategory.ProductSubcategoryID); dbm.AddParameters(1, "@ProductCategoryID", productSubcategory.ProductCategoryID); dbm.AddParameters(2, "@Name", productSubcategory.Name); dbm.AddParameters(3, "@ModifiedDate", DateTime.Now); dbm.ExecuteNonQuery(CommandType.StoredProcedure, "UpdateProductSubcategory"); } catch (Exception ex) { log.Write(ex.Message, "UpdateProductSubcategory"); throw (ex); } finally { dbm.Dispose(); } return(true); }
///<summary> /// Returns a Typed ProductSubcategory Entity with mock values. ///</summary> static public ProductSubcategory CreateMockInstance_Generated(TransactionManager tm) { ProductSubcategory mock = new ProductSubcategory(); mock.Name = TestUtility.Instance.RandomString(24, false);; mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); int count0 = 0; TList <ProductCategory> _collection0 = DataRepository.ProductCategoryProvider.GetPaged(tm, 0, 10, out count0); //_collection0.Shuffle(); if (_collection0.Count > 0) { mock.ProductCategoryId = _collection0[0].ProductCategoryId; } // create a temporary collection and add the item to it TList <ProductSubcategory> tempMockCollection = new TList <ProductSubcategory>(); tempMockCollection.Add(mock); tempMockCollection.Remove(mock); return((ProductSubcategory)mock); }
public void LoadSubCategories(int CategoryId) { if (m_Loading) { return; } string where = "ProductCategoryId=" + CategoryId.ToString(); string order_by = "Name"; ProductSubcategory sub = new ProductSubcategory(); ProductSubcategoryCollection subCol = new ProductSubcategoryCollection(); try { m_Loading = true; subCol = sub.GetProductSubcategoryCollection(where, order_by); sub.ProductCategoryID = 0; sub.ProductSubcategoryID = 0; sub.Name = "All"; sub.ModifiedDate = DateTime.Now; subCol.Insert(0, sub); ddlSubCategory.DataSource = subCol; ddlSubCategory.DisplayMember = "Name"; ddlSubCategory.ValueMember = "ProductSubcategoryId"; m_Loading = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void DeleteSubCategory() { Cursor.Current = Cursors.WaitCursor; ProductSubcategory psc = new ProductSubcategory(); int subID = 0; try { subID = Int32.Parse(lblSubcategoryID.Text); } catch { MessageBox.Show("Select a subcategory to delete", "Product Subcategories", MessageBoxButtons.OK, MessageBoxIcon.Information); Cursor.Current = Cursors.Default; return; } try { psc.ProductSubcategoryID = subID; psc.RemoveProductSubcategory(subID); } catch (Exception ex) { MessageBox.Show(ex.Message, "Product Subcategories", MessageBoxButtons.OK, MessageBoxIcon.Error); Cursor.Current = Cursors.Default; } finally { psc = null; } Cursor.Current = Cursors.Default; }
public ProductSubcategoryCollection GetAllProductSubcategoryCollection() { IDBManager dbm = new DBManager(); ProductSubcategoryCollection cols = new ProductSubcategoryCollection(); try { IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectProductSubcategoriesAll"); while (reader.Read()) { ProductSubcategory productSubcategory = new ProductSubcategory(); productSubcategory.ProductSubcategoryID = Int32.Parse(reader["ProductSubcategoryID"].ToString()); productSubcategory.ProductCategoryID = Int32.Parse(reader["ProductCategoryID"].ToString()); productSubcategory.Name = reader["Name"].ToString(); productSubcategory.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); cols.Add(productSubcategory); } } catch (Exception ex) { log.Write(ex.Message, "GetAllProductSubcategoryCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
private void PopulateProductSubCategories(int catID, ComboBox cmb) { ProductSubcategory sub = new ProductSubcategory(); ProductSubcategory selectNew = new ProductSubcategory(); ProductSubcategoryCollection col = new ProductSubcategoryCollection(); selectNew.ProductSubcategoryID = 0; selectNew.Name = "[Select One]"; string where = "[ProductCategoryID] = " + catID; string orderBy = "Name"; Cursor.Current = Cursors.WaitCursor; try { col = sub.GetProductSubcategoryCollection(where, orderBy); col.Insert(0, selectNew); cmb.DataSource = col; cmb.DisplayMember = "Name"; cmb.ValueMember = "ProductSubCategoryID"; } catch (Exception ex) { MessageBox.Show(ex.Message); Cursor.Current = Cursors.Default; } finally { sub = null; } Cursor.Current = Cursors.Default; }
public ProductSubcategory GetProductSubcategory(int productSubcategoryID) { IDBManager dbm = new DBManager(); ProductSubcategory productSubcategory = new ProductSubcategory(); try { dbm.CreateParameters(1); dbm.AddParameters(0, "@ProductSubcategoryID", productSubcategoryID); IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectProductSubcategory"); while (reader.Read()) { productSubcategory.ProductSubcategoryID = Int32.Parse(reader["ProductSubcategoryID"].ToString()); productSubcategory.ProductCategoryID = Int32.Parse(reader["ProductCategoryID"].ToString()); productSubcategory.Name = reader["Name"].ToString(); productSubcategory.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); } } catch (Exception ex) { log.Write(ex.Message, "GetProductSubcategory"); throw (ex); } finally { dbm.Dispose(); } return(productSubcategory); }
private void UpdateProductsSubCategories(string[] selectedSubCategories, Product productToUpdate) { if (selectedSubCategories == null) { productToUpdate.ProductSubcategories = new List <ProductSubcategory>(); return; } var selectedSubCategoriesHS = new HashSet <string>(selectedSubCategories); var productSubCategories = new HashSet <int> (productToUpdate.ProductSubcategories.Select(c => c.SubCategory.Id)); foreach (var subcat in _context.SubCategories) { if (selectedSubCategoriesHS.Contains(subcat.Id.ToString())) { if (!productSubCategories.Contains(subcat.Id)) { productToUpdate.ProductSubcategories.Add(new ProductSubcategory { ProductId = productToUpdate.Id, SubCategoryId = subcat.Id }); } } else { if (productSubCategories.Contains(subcat.Id)) { ProductSubcategory courseToRemove = productToUpdate.ProductSubcategories.SingleOrDefault(i => i.SubCategoryId == subcat.Id); _context.Remove(courseToRemove); } } } }
public void ExportCategories() { SqlCompactConnection conn = new SqlCompactConnection(); try { StripStatus.Text = "Products Sub Categories.."; ProductSubcategory sub = new ProductSubcategory(); ProductCategory cat = new ProductCategory(); conn.DropProdctSubCategoryTable(); conn.CreateProdctSubCategoryTable(); ProductSubcategoryCollection subCol = sub.GetAllProductSubcategoryCollection(); conn.SynchForm = this; conn.AddProductSubCategory(subCol); StripStatus.Text = "Products Categories.."; conn.DropProdctCategoryTable(); conn.CreateProdctCategoryTable(); ProductCategoryCollection catCol = cat.GetAllProductCategoryCollection(); conn.AddProductCategory(catCol); sub = null; cat = null; subCol = null; catCol = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.CloseDatabase(); conn = null; } }
private List <Breadcrumb> GetBreadcrumbs(ProductCategory category, ProductSubcategory subcategory, ProductGroup group) { List <Breadcrumb> breadcrumbs = new List <Breadcrumb>() { new Breadcrumb("Главная", "/"), new Breadcrumb("Каталог", "/catalog") }; if (category != null) { breadcrumbs.Add(new Breadcrumb(category.Title, $"/catalog/{category.SectionUrl}")); } if (subcategory != null) { breadcrumbs.Add(new Breadcrumb(subcategory.Title, $"/catalog/{subcategory.ProductCategory.SectionUrl}/{subcategory.SectionUrl}")); } if (group != null) { breadcrumbs.Add(new Breadcrumb(group.Title, $"/catalog/{group.ProductCategory.SectionUrl}/{group.ProductSubcategory.SectionUrl}/{group.SectionUrl}")); } return(breadcrumbs); }
/// <summary> /// Deep load all ProductSubcategory children. /// </summary> private void Step_03_DeepLoad_Generated() { using (TransactionManager tm = CreateTransaction()) { int count = -1; mock = CreateMockInstance(tm); mockCollection = DataRepository.ProductSubcategoryProvider.GetPaged(tm, 0, 10, out count); DataRepository.ProductSubcategoryProvider.DeepLoading += new EntityProviderBaseCore <ProductSubcategory, ProductSubcategoryKey> .DeepLoadingEventHandler( delegate(object sender, DeepSessionEventArgs e) { if (e.DeepSession.Count > 3) { e.Cancel = true; } } ); if (mockCollection.Count > 0) { DataRepository.ProductSubcategoryProvider.DeepLoad(tm, mockCollection[0]); System.Console.WriteLine("ProductSubcategory instance correctly deep loaded at 1 level."); mockCollection.Add(mock); // DataRepository.ProductSubcategoryProvider.DeepSave(tm, mockCollection); } //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
public async Task <IActionResult> PutProductSubcategory(int id, ProductSubcategory productSubcategory) { if (id != productSubcategory.SubcategoryId) { return(BadRequest()); } _context.Entry(productSubcategory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductSubcategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public MyProduct(Product product) { this.ProductID = product.ProductID; this.Name = product.Name; this.ProductNumber = product.ProductNumber; this.ProductReviews = product.ProductReviews; this.ProductSubcategory = product.ProductSubcategory; }
///<summary> /// Update the Typed ProductSubcategory Entity with modified mock values. ///</summary> static public void UpdateMockInstance(TransactionManager tm, ProductSubcategory mock) { ProductSubcategoryTest.UpdateMockInstance_Generated(tm, mock); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); }
/// <summary> /// Get product by categoryId /// </summary> /// <param name="category"></param> /// <returns></returns> public static IQueryable<Product> GetProductByCategory(ProductSubcategory category) { IQueryable<Product> prodList = null; prodList = from p in Common.DataEntities.Products where p.ProductSubcategory.ProductSubcategoryID == category.ProductSubcategoryID select p; return prodList; }
public ActionResult Index(int?subcategoryId) { ProductSubcategory prodSubcat = _categoryRepository.GetProductSubcategoryById(subcategoryId.GetValueOrDefault(1)); var productCategories = _categoryRepository.GetProductCategories(); ViewBag.CurrentProductCategoryId = prodSubcat.ProductCategoryID; ViewBag.CurrentProductSubcategoryId = prodSubcat.ProductSubcategoryID; return(PartialView(productCategories)); }
public MyProduct(int productId, string name, string productNumber, int?productSubcategoryId, ProductSubcategory productSubcategory, EntitySet <ProductVendor> productVendors, decimal standardCost) { ProductID = productId; Name = name; ProductNumber = productNumber; ProductSubcategoryID = productSubcategoryId; ProductSubcategory = productSubcategory; ProductVendors = productVendors; StandardCost = standardCost; }
public static ProductSubcategoryViewModel ToViewModel(this ProductSubcategory entity) { return(new ProductSubcategoryViewModel { ProductSubcategoryID = entity.ProductSubcategoryID, ProductCategoryID = entity.ProductCategoryID, Name = entity.Name, ModifiedDate = entity.ModifiedDate }); }
private int AddSubCategory() { int ret = 0; Cursor.Current = Cursors.WaitCursor; ProductSubcategory psc = new ProductSubcategory(); string subCatName = txtSubcategory.Text.Trim(); try { int categoryID = 0; try { categoryID = Int32.Parse(cmbCategories.SelectedValue.ToString()); } catch { categoryID = 0; } if (categoryID > 0) { psc.Name = subCatName; psc.ProductCategoryID = categoryID; int pscid = psc.Exists(psc.Name, psc.ProductCategoryID); if (pscid > 0) { DialogResult result = MessageBox.Show("Product Subcategory " + psc.Name + " already exists\nWould you like to update it?", "MICS", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { psc.UpdateProductSubcategory(psc); MessageBox.Show("Record updated successfully", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Record is not saved", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { psc.AddProductSubcategory(psc); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Product Subcategories", MessageBoxButtons.OK, MessageBoxIcon.Error); Cursor.Current = Cursors.Default; } finally { psc = null; } Cursor.Current = Cursors.Default; return(ret); }
public void ManyToOneReadTest() { using (EasySession easySession = new EasySession()) { ///[Test Read] - many-to-one relationship ProductSubcategory productSubcategory = new ProductSubcategory(); IList resultList = productSubcategory.FindAll(easySession); Assert.AreEqual(38, resultList.Count); } }
public ActionResult Edit([Bind(Include = "ProductSubcategoryID,ProductCategoryID,Name,rowguid,ModifiedDate,isDeleted")] ProductSubcategory productSubcategory) { if (ModelState.IsValid) { db.Entry(productSubcategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductCategoryID = new SelectList(db.ProductCategories, "ProductCategoryID", "Name", productSubcategory.ProductCategoryID); return(View(productSubcategory)); }
/// <summary> /// Test methods exposed by the EntityHelper class. /// </summary> private void Step_20_TestEntityHelper_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); ProductSubcategory entity = mock.Copy() as ProductSubcategory; entity = (ProductSubcategory)mock.Clone(); Assert.IsTrue(ProductSubcategory.ValueEquals(entity, mock), "Clone is not working"); } }
///<summary> /// Returns a Typed ProductSubcategory Entity with mock values. ///</summary> static public ProductSubcategory CreateMockInstance(TransactionManager tm) { // get the default mock instance ProductSubcategory mock = ProductSubcategoryTest.CreateMockInstance_Generated(tm); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); // return the modified object return(mock); }
/// <summary> /// Check the foreign key dal methods. /// </summary> private void Step_10_FK_Generated() { using (TransactionManager tm = CreateTransaction()) { ProductSubcategory entity = CreateMockInstance(tm); bool result = DataRepository.ProductSubcategoryProvider.Insert(tm, entity); Assert.IsTrue(result, "Could Not Test FK, Insert Failed"); TList <ProductSubcategory> t0 = DataRepository.ProductSubcategoryProvider.GetByProductCategoryId(tm, entity.ProductCategoryId, 0, 10); } }
/// <summary> /// Удаляет подкатегорию по идентификатору. /// </summary> /// <param name="id">Идентификатор.</param> public void DeleteSubcategory(int id) { ProductSubcategory subcategory = GetSubcategory(id); if (subcategory == null) { return; } context.ProductSubcategories.Remove(subcategory); Save(); }
// PUT api/awbuildversion/5 public void Put(ProductSubcategory value) { var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault(); if (GetActionType.Key != null) { if (GetActionType.Value.ToList()[0].Equals("DELETE")) adventureWorks_BC.ProductSubcategoryDelete(value); if (GetActionType.Value.ToList()[0].Equals("UPDATE")) adventureWorks_BC.ProductSubcategoryUpdate(value); } }
// GET: Products public ActionResult Category(int id, int page = 1) { using (AdventureWorks2014Context db = new AdventureWorks2014Context()) { ProductSubcategory psc = db.ProductSubcategories.Find(id); IEnumerable <Product> products = psc.Products.OrderBy(p => p.Name).Skip((page - 1) * PageCount).Take(PageCount); ViewBag.Title = psc.Name; ViewBag.ID = id; ViewBag.Page = page; ViewBag.PageMax = Math.Ceiling(psc.Products.Count() / (double)PageCount); return(View(products)); } }
private async Task <bool> BeUniqueByName(ApiProductSubcategoryRequestModel model, CancellationToken cancellationToken) { ProductSubcategory record = await this.productSubcategoryRepository.ByName(model.Name); if (record == null || (this.existingRecordId != default(int) && record.ProductSubcategoryID == this.existingRecordId)) { return(true); } else { return(false); } }
/// <summary> /// Serialize the mock ProductSubcategory entity into a temporary file. /// </summary> private void Step_06_SerializeEntity_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_ProductSubcategory.xml"); EntityHelper.SerializeXml(mock, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock not found"); System.Console.WriteLine("mock correctly serialized to a temporary file."); } }
public async Task <ApiProductSubcategoryResponseModel> ByName(string name) { ProductSubcategory record = await this.ProductSubcategoryRepository.ByName(name); if (record == null) { return(null); } else { return(this.BolProductSubcategoryMapper.MapBOToModel(this.DalProductSubcategoryMapper.MapEFToBO(record))); } }
/// <summary> /// There are no comments for ProductSubcategory in the schema. /// </summary> public void AddToProductSubcategory(ProductSubcategory productSubcategory) { base.AddObject("ProductSubcategory", productSubcategory); }
/// <summary> /// Create a new ProductSubcategory object. /// </summary> /// <param name="productSubcategoryID">Initial value of ProductSubcategoryID.</param> /// <param name="name">Initial value of Name.</param> /// <param name="rowguid">Initial value of rowguid.</param> /// <param name="modifiedDate">Initial value of ModifiedDate.</param> public static ProductSubcategory CreateProductSubcategory(int productSubcategoryID, string name, global::System.Guid rowguid, global::System.DateTime modifiedDate) { ProductSubcategory productSubcategory = new ProductSubcategory(); productSubcategory.ProductSubcategoryID = productSubcategoryID; productSubcategory.Name = name; productSubcategory.rowguid = rowguid; productSubcategory.ModifiedDate = modifiedDate; return productSubcategory; }
// POST api/awbuildversion public void Post(ProductSubcategory value) { adventureWorks_BC.ProductSubcategoryAdd(value); }