private void btnSave_Click(object sender, RoutedEventArgs e) { if (Validate() == false) { return; } if (ProductBLL.GetProductByName(txtboxName.Text) != null) { MessageBox.Show("Productname is already used"); } else { walangforeverRestaurant.Domain.Model.Products products = new walangforeverRestaurant.Domain.Model.Products(); products.Id = Guid.NewGuid(); products.Name = txtboxName.Text; products.CategoryId = this._sender.categoryId; decimal dec = 0; decimal.TryParse(txtboxPrice.Text, out dec); products.Price = dec; MessageBox.Show("Productname successfully created."); ProductBLL.Create(products); this._sender.showList(); this.Close(); } }
public int Create([FromForm] Product product, [FromForm] IFormFile productImage) { byte[] file; using (MemoryStream memoryStream = new MemoryStream()) { productImage.CopyTo(memoryStream); file = memoryStream.ToArray(); } product.Image = System.Guid.NewGuid().ToString(); imageService.Upload(file, product.Image); return(productService.Create(product)); }
private void InitializeAccount(LoginUser loginUser) { //get or create the user into the database. var user = _userBLL.GetUser(loginUser.Operator); if (user != null && user.Id > 0) { LoginManager.Instance.LoginUser.LocalUser = user; } //fetch the Fund, AssetUnit, Portfolio, Holder by UFX. UFXBLLManager.Instance.AccountBLL.QueryAccount(); UFXBLLManager.Instance.AccountBLL.QueryAssetUnit(); UFXBLLManager.Instance.AccountBLL.QueryPortfolio(); UFXBLLManager.Instance.AccountBLL.QueryHolder(); //sync the fund, AssetUnit, Portfolio into database. _productBLL.Create(LoginManager.Instance.Accounts, LoginManager.Instance.Assets, LoginManager.Instance.Portfolios); }
public ActionResult Create(Product product) { try { var iplProduct = new ProductBLL(); var Brand = iplProduct.GetListBrandThy(); ViewBag.Brand = new SelectList(Brand, "brandID", "brandName"); string fileName = Path.GetFileNameWithoutExtension(product.imageFile.FileName); string extension = Path.GetExtension(product.imageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; product.imageLink = ConfigurationManager.AppSettings.Get("SaveImageProduct") + fileName; fileName = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings.Get("SaveImageProduct")), fileName); product.imageFile.SaveAs(fileName); if (ModelState.IsValid) { int res = iplProduct.Create(product); if (res > 0) { int id = iplProduct.GetMaxID(); iplProduct.ActivityLog(id); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Create fail!"); } return(View(product)); } else { return(View()); } } catch { return(View()); } }
public string Post([FromBody] Product product) { return(productBLL.Create(product)); }