public IActionResult Details(string id) { ManufacturerRepo mRepo = new ManufacturerRepo(db); var make = mRepo.Get(id); return(View(make)); }
public IActionResult Edit(string id) { ManufacturerRepo mRepo = new ManufacturerRepo(db); Manufacturer make = mRepo.Get(id); return(View(make)); }
public IActionResult Index() { ManufacturerRepo mRepo = new ManufacturerRepo(db); List <Manufacturer> mList = mRepo.GetAll(); return(View(mList)); }
public void firstTest() { var manufacturerRepo = new ManufacturerRepo(db); var controller = new ManufacturerController(db); int expected = 3; var viewResult = Assert.IsType <ViewResult>(controller.Index()); var model = Assert.IsType <List <Manufacturer> >(viewResult.Model); int actual = model.Count; Assert.Equal(expected, actual); }
public IActionResult Delete(string id) { bool success; success = new ManufacturerRepo(db).Delete(id); if (success) { return(RedirectToAction("Index")); } else { return(RedirectToAction("Error", "Index")); } }
private void LoadDropDownList() { List <ProductType> ProductTypes = new ProductTypeRepo().GetAllProductType(); ddlProductType.DataSource = ProductTypes; ddlProductType.DataBind(); ddlProductType.Items.Insert(0, new ListItem("(All)", "")); List <Manufacturer> Manufacturers = new ManufacturerRepo().GetAllManufacturer(); ddlManufacturer.DataSource = Manufacturers; ddlManufacturer.DataBind(); ddlManufacturer.Items.Insert(0, new ListItem("(All)", "")); }
protected void btnRemove_Click(object sender, EventArgs e) { try { LinkButton lnk = (LinkButton)sender; int Id = ToSQL.SQLToInt(lnk.CommandArgument); if (Id > 0) { int i = new ManufacturerRepo().DeleteManufacturer(Id); BindItemsList(); } } catch { } }
public IActionResult Edit(Manufacturer m) { bool success = false; if (ModelState.IsValid) { success = new ManufacturerRepo(db).Update(m); } if (success) { return(RedirectToAction("Index")); } else { return(RedirectToAction("Error", "Index")); } }
private void initialize() { productVMRepo = new ProductVMRepo(); productRepo = new ProductRepo(); manufacturerVMRepo = new ManufacturerVMRepo(); manufacturerRepo = new ManufacturerRepo(); supplierRepo = new SupplierRepo(); //add database update listener delegate productRepo.DatabaseUpdated += ProductsUpdateListener; dataGridViewProducts.DataSource = bsProducts; comboBoxManufacturer.DataSource = bsManufacturers; comboBoxSupplier.DataSource = bsSuppliers; refreshProductsData(); loadManufacturers(); loadSuppliers(); }
protected void btnSave_Click(object sender, EventArgs e) { Manufacturer manufacturer = new Manufacturer(); manufacturer.Name = ToSQL.EmptyNull(txtName.Text); manufacturer.Phone = ToSQL.EmptyNull(txtPhone.Text); manufacturer.Website = ToSQL.EmptyNull(txtWebsite.Text); manufacturer.Note = ToSQL.EmptyNull(txtNote.Text); manufacturer.IsActive = true; manufacturer.Address = new Address() { Street1 = ToSQL.EmptyNull(txtStreet1.Text), Street2 = ToSQL.EmptyNull(txtStreet2.Text), City = ToSQL.EmptyNull(txtCity.Text), State = ToSQL.EmptyNull(txtState.Text), Country = ToSQL.EmptyNull(txtCountry.Text), ZipCode = ToSQL.EmptyNull(txtZipCode.Text) }; int i = new ManufacturerRepo().CreateManufacturer(manufacturer); Response.Redirect("Management-Manafacturer.aspx"); }
private void AddManufacturerForm_Load(object sender, EventArgs e) { manufacturerRepo = new ManufacturerRepo(); }