// GET: Admin/BrandModels/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BrandModel brandModel = db.BrandModels.Find(id); if (brandModel == null) { return(HttpNotFound()); } return(View(brandModel)); }
private void btnAdd_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtBrandName.Text)) { ClsCommon.ShowErrorToolTip(txtBrandName, "Please Enter The Brand Name"); } else { var model = new BrandModel { BrandId = _brandId, BrandName = txtBrandName.Text, Description = txtRemarks.Text }; if (_isNewMode) { _brandId = _brandService.Save(model); if (_brandId <= 0) { return; } MessageBox.Show(@"Data Saved Successfully", @"Save", MessageBoxButtons.OK, MessageBoxIcon.Information); var frm = (FrmBrand)_frmForm; frm.grdData.Rows.Add(_brandId, model.BrandName, model.Description); frm.grdData.Rows[frm.grdData.Rows.Count - 1].IsSelected = true; txtBrandName.Focus(); txtBrandName.Text = ""; txtRemarks.Text = ""; Notify(); } else { var success = _brandService.Update(model); if (!success) { return; } MessageBox.Show(@"Data Updated Successfully", @"Update", MessageBoxButtons.OK, MessageBoxIcon.Information); var frm = (FrmBrand)_frmForm; frm.grdData.CurrentRow.Cells["BrandName"].Value = model.BrandName; frm.grdData.CurrentRow.Cells["Description"].Value = model.Description; Notify(); Close(); } } }
public List <BrandModel> Execute() { var brands = _repo.Brand.GetAllWithInclude(); var result = new List <BrandModel>(); foreach (var brand in brands) { var newBrandModel = new BrandModel { Id = brand.Id, BrandName = brand.BrandName, AdressId = brand.AdressId, ContactPerson = brand.ContactPerson, Email = brand.Email, Phone = brand.Phone, WebSite = brand.WebSite, Adress = new AdressModel { Id = brand.Adress.Id, Street = brand.Adress.Street, StreetBus = brand.Adress.StreetBus, StreetNumber = brand.Adress.StreetNumber, PostCityId = brand.Adress.PostCityId, CountryId = brand.Adress.CountryId, } }; if (brand.Adress.PostCity != null) { newBrandModel.Adress.PostCity = new PostCityModel { PostCode = brand.Adress.PostCity?.PostCode, City = brand.Adress.PostCity.City, Province = brand.Adress.PostCity?.Province, SubMunicipality = brand.Adress.PostCity?.SubMunicipality }; } if (brand.Adress.Country != null) { newBrandModel.Adress.Country = new CountryModel { CountryName = brand.Adress.Country?.CountryName }; } result.Add(newBrandModel); } return(result); }
public async Task <BrandModel> Create(BrandModel brand) { var validator = new BrandModelValidator().Validate(brand); if (!validator.IsValid) { var error = validator.Errors; throw new TaskSchedulerException(); } var mapping = this.mapper.Map <BrandModel, Brand>(brand); var add = await this.brandRepository.InsertIntoDatabase(mapping); return(this.mapper.Map <Brand, BrandModel>(add)); }
/// <summary> /// /// </summary> /// <param name="brand"></param> /// <returns></returns> public string UpdateBrandDetail(BrandModel brand) { Brand brandToUpdate = new Brand(); brandToUpdate.Id = brand.Id; brandToUpdate.BrandName = brand.BrandName; brandToUpdate.Notes = brand.Notes; brandToUpdate.IsActive = brand.IsActive; brandToUpdate.UpdateUserName = "******"; brandToUpdate.UpdateDttm = DateTime.UtcNow; string result = _brandDataAccess.UpdateBrandDetails(brandToUpdate); return(result); }
public static BrandModel SelectBrandByID(BrandModel brandModel) { try { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { var output = cnn.Query <BrandModel>("SELECT * FROM Tbl_Brand WHERE Id_Brand = @IdBrand", brandModel); return(output.Single()); } } catch (Exception ex) { return(null); } }
//-----------METODOS SE ACME DE LA MARCA--------------------- public static bool InsertBrand(BrandModel brandModel) { try { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute("INSERT INTO Tbl_Brand(Name) VALUES(@Name)", brandModel); return(true); } } catch (Exception ex) { throw; } }
public static bool DeleteBrandById(BrandModel brandModel) { try { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute("DELETE FROM Tbl_Brand WHERE Id_Brand = @Id_Brand", brandModel); return(true); } } catch (Exception ex) { throw; } }
public static bool UpdateBrandById(BrandModel brandModel) { try { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute("UPDATE Tbl_Brand SET Name = @Name WHERE Id_Brand = @Id_Brand", brandModel); return(true); } } catch (Exception ex) { throw; } }
// GET: Admin/Brand public ActionResult Index() { if (Session["Account"] == null) { return(RedirectToAction("Index", "Login", new { area = "" })); } else { Session["URL"] = null; var brand = new BrandModel(); var model = brand.ListAllBrand(); ViewBag.Brand = model; return(View()); } }
protected void UpdateLocales(Brand productAttribute, BrandModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(productAttribute, x => x.Name, localized.Name, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(productAttribute, x => x.Description, localized.Description, localized.LanguageId); } }
public ActionResult Save() { BrandModel brand = new BrandModel(); brand.status = BaseModel.STATUS_ACTIVATE; brand = ObjectUtil.Eval(brand, Request.Params, "", ""); if (string.IsNullOrEmpty(brand.brandID)) { brand.brandID = brand.createPk().ToString(); } JsResultObject result = BaseZdBiz.SaveOrUpdate(brand, "连锁品牌"); return(JsonText(result, JsonRequestBehavior.AllowGet)); }
public JsonResult GetBrandDetails(int id) { using (var db = new PolishWarehouseEntities()) { try { var bm = new BrandModel(id); return(Json(bm)); } catch (Exception ex) { return(Json(ex.Message)); } } }
/// <summary> /// Delete a brand from brand /// </summary> /// <param name="Brand"></param> public static bool DeleteBrand(BrandModel Brand) { try { using (IDbConnection cnn = new MySqlConnection(LoadConnectionString())) { cnn.Execute("DELETE FROM brand WHERE idBrand = @idBrand", Brand); } return(true); } catch (Exception) { throw; } }
// GET: Admin/BrandModels/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BrandModel brandModel = db.BrandModels.Find(id); if (brandModel == null) { return(HttpNotFound()); } ViewBag.BrandId = new SelectList(db.Brands, "Id", "Name", brandModel.BrandId); return(View(brandModel)); }
/// <summary> /// TODO: /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <bool> SaveBrand(BrandModel model) { var entity = model.MapTo <Brand>(); if (model.Id < 1) { await _brandRepository.Insert(entity); } else { await _brandRepository.Update(entity); } return(true); }
//-----------METODOS SE ACME DE LA MARCA--------------------- public static bool InsertBrand(string name) { try { BrandModel brandModel = new BrandModel() { Name = name }; return(BrandConnection.InsertBrand(brandModel)); } catch (Exception ex) { throw; } }
/// <summary> /// Implementación de <see cref="IBrandQueryRepository.Get(int)"/> /// </summary> public async Task <BrandModel> Get(int id) { BrandModel result = null; try { var query = BrandModelQuery(Context).Where(x => x.Id == id); result = await query.SingleOrDefaultAsync(); } catch (Exception ex) { throw; } return(result); }
public static BrandModel SelectBrandByName(string name) { try { BrandModel brandModel = new BrandModel() { Name = name }; return(BrandConnection.SelectBrandByName(brandModel)); } catch (Exception ex) { throw; } }
public static BrandModel SelectBrandByID(int id) { try { BrandModel brandModel = new BrandModel() { Id_Brand = id }; return(BrandConnection.SelectBrandByID(brandModel)); } catch (Exception ex) { throw; } }
/// <summary> /// 查询所有品牌 /// </summary> /// <returns></returns> public List <BrandModel> SelectAllBrand() { pbxdatasourceDataContext pdc = new pbxdatasourceDataContext(connectionString); List <BrandModel> list = new List <BrandModel>(); var info = pdc.brand; foreach (var temp in info) { BrandModel bm = new BrandModel(); bm.BrandAbridge = temp.BrandAbridge; bm.BrandName = temp.BrandName; list.Add(bm); } return(list); }
public static bool DeleteBrandById(int id) { try { BrandModel brandModel = new BrandModel() { Id_Brand = id }; return(BrandConnection.DeleteBrandById(brandModel)); } catch (Exception ex) { throw; } }
public ActionResult Translate(BrandModel model, string culture, string @return) { var brandKey = new EntityKey(typeof(Brand), model.Id); var brand = _brandService.Find(model.Id); var props = new List <PropertyTranslation> { new PropertyTranslation("Name", brand.Name, model.Name), new PropertyTranslation("Description", brand.Description, model.Description) }; _translationStore.AddOrUpdate(CultureInfo.GetCultureInfo(culture), brandKey, props); return(AjaxForm().RedirectTo(@return)); }
public ActionResult Index(string metatitle, int id, string orderby = "") { if (metatitle.Length <= 0 && metatitle.Split('-').Count() < 2) { return(RedirectToAction("NotFound", "Error")); } var brandInfo = BrandModel.GetBrandByID(id); if (brandInfo == null) { return(RedirectToAction("NotFound", "Error")); } ViewBag.OrderBy = orderby; return(View(brandInfo)); }
public async Task AddBrands_NegativeTest() { BrandModel brandModel = new BrandModel() { BrandName = "Hero" }; Mock <IModelManager> mockObject = new Mock <IModelManager>(); mockObject.Setup(x => x.AddBrand(brandModel)); var api = new AdminController(mockObject.Object); var res = (RedirectToRouteResult)await api.AddBrand(brandModel); Assert.AreNotEqual(res.RouteValues["action"], "Brand"); }
// GET: /BrandModel/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BrandModel brandmodel = db.BrandModel.Find(id); if (brandmodel == null) { return(HttpNotFound()); } PopulateManufacturerDropDownList(brandmodel.ManufacturerID); return(View(brandmodel)); }
/// <summary> /// Insert a brand en the table brand /// </summary> /// <param name="Brand"></param> public static bool InsertBrand(BrandModel Brand) { try { using (IDbConnection cnn = new MySqlConnection(LoadConnectionString())) { cnn.Execute("INSERT INTO brand(Name) VALUES(@Name)", Brand); } return(true); } catch (Exception ex) { throw; } }
/// <summary> /// Update a brand from brand /// </summary> /// <param name="Brand"></param> public static bool UpdateBrand(BrandModel Brand) { try { using (IDbConnection cnn = new MySqlConnection(LoadConnectionString())) { cnn.Execute("UPDATE brand SET Name = @Name WHERE idBrand = @idBrand", Brand); } return(true); } catch (Exception ex) { throw; } }
private void btnUpdateProduct_Click(object sender, EventArgs e) { string id = dgvProduct.CurrentRow.Cells[0].Value.ToString(); string code = txtCode.Text; string style = txtStyle.Text; BrandModel brand = (BrandModel)cmbBrand.SelectedItem; bool ivi = true; string description = txaDescription.Text; SubCategoryModel subcategory = (SubCategoryModel)cmbSubcategory.SelectedItem; bool nonExistingInvoice = true; string enterQuantity = txtEnterQuantity.Text; string estableQuantity = txtEstableQuantity.Text; string unityPrice = txtNormalPrice.Text; string lowerPrice = txtLowerPrice.Text; if (rbIviExcent.Checked) { ivi = false; } if (rbNonexistingNoPermit.Checked) { nonExistingInvoice = false; } if (!string.IsNullOrEmpty(file)) { photo = ImageManagement.ImageToByte(file); } try { if (ProductManagement.UpdateProductById(id, code, style, brand.IdBrand.ToString(), description, subcategory.idsubCategory.ToString(), unityPrice, lowerPrice, estableQuantity, enterQuantity, photo, ivi, nonExistingInvoice)) { dgvProduct.DataSource = ProductManagement.SelectAllProducts(); FrmMain.Instance.ToolStripLabel.Text = "Se modifico el producto correctamente"; } else { FrmMain.Instance.ToolStripLabel.Text = "Error, no se pudo modificar el producto"; } } catch (Exception) { throw; } }
public List <BrandModel> GetHiearchyList(List <BrandModel> lstAll, BrandModel node) { var lstChilds = lstAll.Where(ds => ds.parent_brand_id == node.brand_id).ToList(); if (lstChilds.Count == 0) { return(null); } for (int i = 0; i < lstChilds.Count; i++) { var childs = GetHiearchyList(lstAll, lstChilds[i]); lstChilds[i].type = (childs == null || childs.Count == 0) ? "leaf" : ""; lstChilds[i].children = childs; } return(lstChilds.OrderBy(s => s.brand_id).ToList()); }