public IActionResult Create(AccountInfo account) { Random rand = new Random(); int id = rand.Next(10, 1000); account.ClientId = id; _account.AddAccount(account); return(View("Success", account)); }
public IActionResult Post([FromBody] Account account) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } accountRepository.AddAccount(account); return(StatusCode(StatusCodes.Status201Created)); }
private void Button_Click(object sender, RoutedEventArgs e) { decimal startBalance; var chosenClient = clientCombo.SelectedItem as Client; if (decimal.TryParse(balanceBox.Text, out startBalance) && chosenClient != null) { IAccount acc = Factory.Instance.GAccount(); acc.AddAccount(chosenClient.Id, startBalance); UpdateAccount?.Invoke(); balanceBox.Text = null; clientCombo.SelectedItem = null; MessageBox.Show("You've successfully added a new account"); } else { MessageBox.Show("Invalid input data"); } }
public IActionResult Add(AccountViewModel accountViewModel) { try { var result = _accountService.AddAccount(accountViewModel); if (result != null) { ViewBag.msg = "Done"; return(RedirectToAction("Index")); } else { ViewBag.msg = "Failed"; return(View("Add", accountViewModel)); } } catch { ViewBag.msg = "Failed"; return(View("Add", accountViewModel)); } }
public async Task <ServiceResponse <Account> > AddAccount(Account account) { return(await _account.AddAccount(account)); }