private void Create(Product product) { ProductBusiness productBusiness = new ProductBusiness(); int productId = productBusiness.Create(product); MessageBox.Show($"Produto ID {productId} cadastrado com sucesso!", "Sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public PartialViewResult SearchProduct(FormCollection dateRange) { var dateFrom = dateRange["From"]; var dateTo = dateRange["To"]; var viewmodel = new ProductViewModel(); viewmodel.ProductList = new List <ProductViewModel>(); if (dateFrom != null && dateTo != null) { var productList = ProductBusiness.GetProductsByDateRange(dateFrom, dateTo); if (productList != null) { foreach (var item in productList) { var product = new ProductViewModel(); product.Id = item.Id; product.CategoryId = item.CategoryId; product.CategoryDescription = item.CategoryDescription; product.ManufacturerId = item.ManufacturerId; product.ManufacturerName = item.ManufacturerName; product.Name = item.Name; product.Description = item.Description; product.Model = item.Model; product.ReleasedDate = item.ReleasedDate; product.ReleasedYear = item.ReleasedYear; viewmodel.ProductList.Add(product); } result = true; } } return(PartialView("Product", viewmodel)); }
protected void udpate_Click(object sender, EventArgs e) { //se instancia el objeto user para poder utilizar sus atributos Product product = new Product(); product.name = TextBox2.Text; product.description = TextBox3.Text; product.code = Int32.Parse(TextBox4.Text); product.inStock = Int32.Parse(TextBox5.Text); product.weight = TextBox6.Text; product.urlImage = TextBox7.Text; product.category = DropDownList1.Text; product.price = float.Parse(TextBox8.Text); ProductBusiness.Edit(product, TextBox1.Text); this.TextBox1.Text = ""; this.TextBox2.Text = ""; this.TextBox3.Text = ""; this.TextBox4.Text = ""; this.TextBox5.Text = ""; this.TextBox6.Text = ""; this.TextBox7.Text = ""; this.TextBox8.Text = ""; //cuando se presione sobre el boton //se llenara el Gridview con los datos GridView2.DataSource = ProductBusiness.getProducts().ToList(); GridView2.DataBind(); }
// Carga la información del data grid view private void loadDgv() { ProductBusiness ProductBusiness = new ProductBusiness(); try { ProductList = ProductBusiness.listProducts(); dgvProductList.DataSource = ProductList; hideColumns(); reloadImg(ProductList[0].URLimage); reloadName(ProductList[0].Name); reloadDescription(ProductList[0].Description); txtBoxDescription.ReadOnly = true; this.dgvProductList.Rows[0].Selected = true; this.dgvProductList.CurrentCell = this.dgvProductList.Rows[0].Cells[1]; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public async Task <IActionResult> AddProductAsync(ProductParam productParam) { bool isProductParamInserted = false; try { ProductBusiness productBusiness = new ProductBusiness(); if (productParam != null) { productBusiness = mapper.Map <ProductBusiness>(productParam); isProductParamInserted = await productService.AddProductAsync(productBusiness); } if (isProductParamInserted == true) { return(Ok()); } else { return(StatusCode(400)); } } catch (Exception) { return(StatusCode(500)); } }
private void BindData(int nPageIndex) { string strWhere = string.Empty; int nCount = 0; if (ddlProject.SelectedValue.Trim().Length > 0) { strWhere += string.Format(" AND D.PROJECTID={0} ", ddlProject.SelectedValue); } if (txtProductName.Text.Trim().Length > 0) { strWhere += string.Format(" AND D.PRODUCTNAME='{0}' ", ValidatorHelper.SafeSql(txtProductName.Text.Trim())); } if (ddlStauts.SelectedValue.Trim().Length > 0) { strWhere += string.Format(" AND D.PRODUCTFLAG={0} ", ddlStauts.SelectedValue); } DataTable dt = ProductBusiness.GetProductList(nPageIndex, GlobalConsts.PageSize_Default, strWhere, out nCount); rptProductInfo.DataSource = dt; rptProductInfo.DataBind(); PageBar1.PageSize = GlobalConsts.PageSize_Default; PageBar1.PageIndex = nPageIndex; PageBar1.RecordCount = nCount; PageBar1.Draw(); }
public HttpResponseMessage Get(int sku) { HttpResponseMessage msg = null; var oBus = new ProductBusiness(); try { if (sku == 0) { throw new Exception("invalid sku"); } var product = oBus.Get(sku); msg = Request.CreateResponse(HttpStatusCode.OK, product); } catch (Exception ex) { msg = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); } finally { oBus = null; } return(msg); }
public Product Find(int id) { try { var bc = new ProductBusiness(); var product = bc.GetById(id); if (product == null) { var httpError = new HttpResponseMessage() { StatusCode = HttpStatusCode.NotFound, ReasonPhrase = "Product not found", }; throw new HttpResponseException(httpError); } return(product); } catch (HttpResponseException ex) { throw; } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, Content = new StringContent(ex.Message), }; throw new HttpResponseException(httpError); } }
private void AddProduct_Load(object sender, EventArgs e) { // Fills combo box of Brand and Category ProductBusiness businessAux = new ProductBusiness(); try { cboBrand.DataSource = businessAux.listBrands(); cboCategory.DataSource = businessAux.listCategory(); if (product != null) { this.txtBoxCode.Text = product.Code.ToString(); this.txtBoxName.Text = product.Name.ToString(); this.txtBoxDescription.Text = product.Description.ToString(); this.cboBrand.SelectedItem = product.Brand.ToString(); this.cboCategory.SelectedItem = product.Category.ToString(); this.txtBoxUrl.Text = product.URLimage.ToString(); this.txtBoxPrice.Text = product.Price.ToString(); this.txtBoxStock.Text = product.Quantity.ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public async Task ShouldRetrieveAllProducts() { List <Product> prodList = new List <Product>() { new Product { catogeryId = 1, ProductId = 1, ProductName = "Anchor" }, new Product { catogeryId = 1, ProductId = 2, ProductName = "Highland" } }; _repo.Setup(x => x.GetAllAsync()).ReturnsAsync(prodList); _uow.Setup(m => m.ProductRepository).Returns(_repo.Object); var productBusiness = new ProductBusiness(_uow.Object); List <ProductModel> products = await productBusiness.getAllProducts().ConfigureAwait(false); Assert.NotNull(products); Assert.IsAssignableFrom <List <ProductModel> >(products); Assert.Equal(2, products.Count); }
public async Task ShouldDeleteProduct() { var prod = new Product() { catogeryId = 1, ProductId = 1, ProductName = "Anchor" }; var product = new ProductModel() { catogeryId = 1, ProductId = 1, ProductName = "Anchor" }; var _repo = new Mock <IAsyncRepository <Product> >(); _repo.Setup(x => x.DeleteAsync(prod)); await _repo.Object.DeleteAsync(prod); _uow.Setup(m => m.ProductRepository).Returns(_repo.Object); var productBusiness = new ProductBusiness(_uow.Object); await productBusiness.deleteProduct(product).ConfigureAwait(false); _repo.Setup(x => x.SingleOrDefaultAsync(x => x.ProductId == 1)); _repo.Object.SingleOrDefaultAsync(x => x.ProductId == 1).GetAwaiter().Equals(null); _repo.Verify(x => x.DeleteAsync(prod), Times.Once); }
public ActionResult LayDanhSachProductTheoCategory(string Id) { ProductBusiness productBusiness = new ProductBusiness(); List <Product> lstProduct = productBusiness.LayDanhSachProductTheoCategory(Id); return(View(lstProduct)); }
public ActionResult ChiTiet4(int Id) { ProductBusiness productBusiness = new ProductBusiness(); Product objProduct = productBusiness.ChiTietProductTheoId(Id); return(View(objProduct)); }
/// <summary> /// 加载项目的功能菜单 /// </summary> /// <param name="context"></param> /// <returns></returns> private string LoadFunMenu(HttpContext context) { StringBuilder sbContent = new StringBuilder(); string strProjectId = CommonMethod.FinalString(context.Request.QueryString["pid"]); string strProductId = CommonMethod.FinalString(context.Request.QueryString["did"]); DataTable dtProjectFunMenu = ProjectFunBusiness.GetFunMenuList(" AND PROJECTID=" + strProjectId); DataRow[] drowCurFun = dtProjectFunMenu.Select(" FMPARENTID=0 ", "FMSORTNUM DESC"); string strChecked = string.Empty; for (int i = 0; i < drowCurFun.Length; i++) { if (strProductId.Length > 0)//修改时判断是否选中 { strChecked = ProductBusiness.IsProductExistFun(strProductId, drowCurFun[i]["FMID"].ToString()) ? "checked='checked'" : ""; } sbContent.Append("<table class=\"table\" style=\"float:left; width:33%; margin-left:3px;\">"); sbContent.AppendFormat("<tr><td class='rhead' style=\"text-align:left;background-image: url('../../Resource/images/searchthead.gif');\" ><input type='checkbox' onclick='CheckAll({1});' name='{0}' id='{1}' value='{1}' {3} />{2}</td></tr>", "fun", drowCurFun[i]["FMID"], drowCurFun[i]["FMNAME"], strChecked); //下面的子菜单 ReConstructionDataRow(dtProjectFunMenu, System.Convert.ToInt32(drowCurFun[i]["FMID"]), sbContent, strProductId, drowCurFun[i]["FMID"].ToString()); sbContent.Append("</table>"); if ((i + 1) % 3 == 0) { sbContent.Append("</br>"); } } return(sbContent.ToString()); }
public WorkflowUtilities() { this._flexableDto = new OrderDto(); this._validate = new ValidationTools(); this._stateBus = new StateBusiness(); this._prodBus = new ProductBusiness(); }
public async Task <HttpResponseMessage> Post() { var category = HttpContext.Current.Request.Form.Get("category"); string uploadRootPath = HttpContext.Current.Server.MapPath("~/App_Data"); var uploadPath = Path.Combine(uploadRootPath, category); if (!Directory.Exists(uploadPath)) { Directory.CreateDirectory(uploadPath); } ImageStreamProvider streamProvider = new ImageStreamProvider(uploadPath); await Request.Content.ReadAsMultipartAsync(streamProvider); FileInfo fileInfo = new FileInfo(streamProvider.FileData[0].LocalFileName); ProductBusiness productBusiness = new ProductBusiness() { Name = streamProvider.FormData.Get("name"), Stock = Convert.ToInt32(streamProvider.FormData.Get("stock")), Brand = streamProvider.FormData.Get("brand"), Category = streamProvider.FormData.Get("category"), Description = streamProvider.FormData.Get("description"), Price = Convert.ToDouble(streamProvider.FormData.Get("price")), ImageName = fileInfo.Name }; if (_productService.AddProduct(productBusiness)) { return(Request.CreateResponse(HttpStatusCode.Created)); } return(Request.CreateResponse(HttpStatusCode.BadRequest)); }
public JsonResult addReview(string json_review) { var JsonReview = new JavaScriptSerializer().Deserialize <List <ReviewDTO> >(json_review); var review = new Review(); foreach (var item in JsonReview) { review.Content = item.Content; review.Rating = item.Rating; review.CreatedDate = DateTime.Now; review.User_ID = item.User_ID; review.Product_ID = item.Product_ID; review.Status = true; } var res = new ProductBusiness().addReview(review); if (res) { return(Json(new { status = true })); } else { return(Json(new { status = false })); } }
//PUT: api/Products public ProductDTO Put(UpdateProductDTO product) { ProductBusiness productBusiness = new ProductBusiness() { Id = product.Id, Name = product.Name, Description = product.Description, Price = product.Price, Category = product.Category, Brand = product.Brand, ImageName = product.ImageName, Stock = product.Stock }; var updatedProduct = _productService.UpdateStockProduct(productBusiness, product.NewStock); ProductDTO productDTO = new ProductDTO() { Id = updatedProduct.Id, Name = updatedProduct.Name, Description = updatedProduct.Description, Price = updatedProduct.Price, Category = updatedProduct.Category, Brand = updatedProduct.Brand, ImageName = updatedProduct.ImageName, Stock = updatedProduct.Stock }; return(productDTO); }
protected void lnkStopUse_Click(object sender, EventArgs e) { if (hidProductId.Value.Trim().Length > 0 && hidStatus.Value.Trim().Length > 0) { #region 日志记录 USER_SHARE_LOGMODEL log = new USER_SHARE_LOGMODEL(); log.LOGID = CommonBusiness.GetSeqID("S_USER_SHARE_LOG"); log.OPERATECONTENT = "更改产品状态为:" + EnumPlus.GetEnumDescription(typeof(ShareEnum.ProductFlag), hidStatus.Value); log.OPERATECONTENT += ",产品Id:" + hidProductId.Value; log.OPERATEDATE = DateTime.Now; log.OPERATETYPE = int.Parse(ShareEnum.LogType.ChangeProductStatus.ToString("d")); log.OPERATORID = AccountId; log.PROJECTID = ProjectId; #endregion #region 保存 if (ProductBusiness.UpdateProductStatus(hidProductId.Value, hidStatus.Value, log)) { Alert("操作成功!"); BindData(0); } else { Alert("操作失败,请重试!"); } #endregion } }
protected void Button1_Click(object sender, EventArgs e) { //cuando se presione sobre el boton //se llenara el Gridview con los datos GridView2.DataSource = ProductBusiness.getProducts().ToList(); GridView2.DataBind(); }
public HttpResponseMessage Post([FromBody] Product product) { HttpResponseMessage msg = null; var oBus = new ProductBusiness(); try { //Verificar antes de incluir var productTest = oBus.Get(product.sku); if (productTest != null) { msg = Request.CreateResponse(HttpStatusCode.BadRequest, "Product exists"); } else { oBus.Create(product); msg = Request.CreateResponse(HttpStatusCode.OK); } } catch (Exception ex) { msg = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); } finally { oBus = null; } return(msg); }
public async Task <bool> AddProductAsync(ProductBusiness productBusiness) { try { if (productBusiness == null) { throw new ArgumentNullException(nameof(productBusiness)); } var product = mapper.Map <Product>(productBusiness); product.products = product.Name != "" ? product.Name : "product"; await _context.Products.InsertOneAsync(product); var insertedProduct = await _context.Products .Find(p => p.ProductId == product.ProductId || p.InternalId == product.InternalId) .Limit(1) .FirstOrDefaultAsync(); if (insertedProduct != null) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
static void Main() { ProductBusiness obj = new ProductBusiness(); //obj.AjouterProduit(); Application.Run(new Accueil()); }
public ActionResult LoadAllCategoryAndProduct() { var db = new ProductBusiness(); var result = db.BS_LoadAllCategoryAndProduct(); return(PartialView(result)); }
public ToTheFieldController() { _productBusiness = new ProductBusiness(); _product_dateBusiness = new product_dateBusiness(); _dictionaryBusiness = new DictionaryBusiness(); _teamBusiness = new TeamBusiness(); }
public IActionResult Index() { var token = User.Claims.Where(x => x.Type == ClaimTypes.NameIdentifier).FirstOrDefault().Value; List <Product> form = new ProductBusiness().GetProducts(token).Result; return(View(form)); }
public ActionResult Index() { ProductViewModel viewmodel = new ProductViewModel(); viewmodel.ProductList = new List <ProductViewModel>(); var productList = ProductBusiness.GetProducts(); foreach (var item in productList) { var product = new ProductViewModel(); product.Id = item.Id; product.CategoryId = item.CategoryId; product.CategoryDescription = item.CategoryDescription; product.ManufacturerId = item.ManufacturerId; product.ManufacturerName = item.ManufacturerName; product.Name = item.Name; product.Description = item.Description; product.Model = item.Model; product.ReleasedDate = item.ReleasedDate; product.ReleasedYear = item.ReleasedYear; viewmodel.ProductList.Add(product); } return(View(viewmodel)); }
public IActionResult Save(ProductViewModel productViewModel) { Product product = new Product() { ProductName = productViewModel.ProductName, ProductBarcode = productViewModel.ProductBarcode, ProductIsActive = true, ProductPrice = productViewModel.ProductPrice, ProductUnit = productViewModel.ProductUnit, ProductDescryption = productViewModel.ProductDescryption }; if (productViewModel.ProductPhoto != null) { string folder = "Images/Product/"; folder += Guid.NewGuid().ToString() + "_" + productViewModel.ProductPhoto.FileName; string serverFolder = Path.Combine(_webHostEnvironment.WebRootPath, folder); productViewModel.ProductPhoto.CopyToAsync(new FileStream(serverFolder, FileMode.Create)); product.ProductImageUrl = '/' + folder; } else { product.ProductImageUrl = productViewModel.ProductImageUrl; } var token = User.Claims.Where(x => x.Type == ClaimTypes.NameIdentifier).FirstOrDefault().Value; var add = new ProductBusiness().AddProduct(product, token).Result; List <Product> form = new ProductBusiness().GetProducts(token).Result; return(View("Index", form)); }
protected void btSearch_Click(object sender, EventArgs e) { if (ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text)) != null) { //mandamos los datos que ya estan ingresado al formulario para poder editarlos TextBox2.Text = ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["name"] != null? ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["name"].ToString() : string.Empty; TextBox3.Text = ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["description"] != null? ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["description"].ToString() : string.Empty; TextBox4.Text = ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["code"] != null? ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["code"].ToString() : string.Empty; TextBox5.Text = ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["inStock"] != null? ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["inStock"].ToString() : string.Empty; TextBox6.Text = ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["weight"] != null? ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["weight"].ToString() : string.Empty; TextBox7.Text = ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["urlImage"] != null? ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["urlImage"].ToString() : string.Empty; TextBox8.Text = ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["price"] != null? ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["price"].ToString() : string.Empty; DropDownList1.Text = ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["category"] != null? ProductBusiness.SearchByID(ObjectId.Parse(TextBox1.Text))["category"].ToString() : string.Empty; } }
public ActionResult Detail(long ID) { var model = new ProductBusiness(); var product = model.getProductDetail(ID); var serial_type = model.GetSerial_TypesByID(ID); ViewBag.product_detail = product; ViewBag.serial_type_product = serial_type; var lstColor = new List <Serial_TypeDTO>(); bool isSize = false; foreach (var item in serial_type) { if (item.Color != null) { var ser = new Serial_TypeDTO(); ser.Color = item.Color; ser.ID = item.ID; lstColor.Add(ser); } if (item.Size != null) { isSize = true; } } ViewBag.lstColor = lstColor; ViewBag.isSize = isSize; ViewBag.lstProductRecommend_1 = model.getProductRecommend(); ViewBag.lstProductRecommend_2 = model.getProductRecommend(); ViewBag.lstSameCategory = model.getProductByCategoryID(product.Category_ID); ViewBag.lstReview = model.getReview(ID); return(View()); }
// GET api/values/5 public Product Get(Guid Id) { ProductBusiness productBusiness = new ProductBusiness(); var list = productBusiness.GetAll(); return(list.FirstOrDefault(p => p.Id == Id)); }
public override async Task OnConnected() { _busiProduct = new ProductBusiness(); var prod = _busiProduct.TumunuGetir(); await Clients.Caller.getAllProcuts(prod); }