public ActionResult AddStock(int id, string symbol) { var user = _userRepo.GetUserById(id); //check to make sure a user was returned from _userRepo.LoginUser if (user != null) { ApiHelper.InitializeClient(); var s = _stockFactory.LoadStock(symbol).GetAwaiter().GetResult(); _stockRepo.AddStock(user, s); return(Ok(StatusCode(201))); // return AuthenticateUser(userViewModel); } return(NotFound()); }
private void btnAddProduct_Click(object sender, EventArgs e) { try { decimal quantity = 0; if (radIsBulk.Checked) { quantity = Convert.ToDecimal(Convert.ToDecimal(txtQuantity.Text) * Convert.ToInt32(txtSinglesInBulk.Text)); } else { quantity = Convert.ToDecimal(txtQuantity.Value); } for (int i = 0; i <= 3; i++) { if (i == 1) { if (ValidateForm() == true) { int update = ProductRepo.AddProducts(txtBQNum.Text, Convert.ToInt32(quantity), Convert.ToDecimal(txtUnitPrice.Text));//this version of AddProducts(x,x,x,x) taking 4 params if actually for updating the products tab if the product BQ already exists. if (update > 0) { continue; } else { int ins = ProductRepo.AddProducts(txtBQNum.Text, txtProductNames.Text, Convert.ToInt32(quantity), Convert.ToInt32(txtSinglesInBulk.Text), Convert.ToDecimal(txtBulkPrice.Text), Convert.ToDecimal(txtUnitPrice.Text), txtDescription.Text, Convert.ToInt32(txtLowAlert.Text));//AddProducts(x,x,x,x,x,x,x,x,x,x,x) taking 11 params actually add the products to the database if its BQ doesnt exist in the database if (ins <= 0) { lblError.Text = "Error while inserting product"; break; } else { continue; } } } else { lblError.Text = "Error in data entry"; } break; } if (i == 2) { string bulkType;; if (radIsBulk.Checked) { bulkType = cboBulkType.Text; } else { bulkType = "single"; } lblError.Text = "Managing Stock..."; int stockInsert = StockRepo.AddStock(txtBQNum.Text, Convert.ToInt32(txtQuantity.Value), Convert.ToDecimal(txtUnitPrice.Text), txtDescription.Text, bulkType, Convert.ToDateTime(dtpExpiryDate.Text));//Making the next loop phase add and manage stock if (stockInsert > 0) { continue; } else { lblError.Text = "Error adding stock"; break; } } if (i > 2) { timer1.Enabled = true; lblError.Text = "Product added and stock updated"; ClearForm(); } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }