public async Task <ActionResult <CashAccounts> > PostCashAccounts(CashAccounts cashAccounts) { _context.CashAccounts.Add(cashAccounts); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCashAccounts", new { id = cashAccounts.CashAccountId }, cashAccounts)); }
/// <summary> /// Открывает новый счет с пустым балансом /// </summary> /// <param name="status"></param> /// <param name="num"></param> public void NewCashAcc(string status, string num) { string inn = ""; string pass = ""; string sql = ""; CashAccounts ca = new CashAccounts() { AccFinance = 0, Active = true, NumCashAcc = GetNewCashAcc(), PeriodAcc = DateTime.Now.AddYears(5), TypeAcc = "DEPOSITE" }; try { if (status == "COMPANY") { inn = num; ca.NumClientINN = num; sk.CashAccounts.Local.Add(ca); } else { pass = num; ca.NumClientPassport = num; sk.CashAccounts.Local.Add(ca); } sk.SaveChanges(); } catch (Exception e) { MessageBox.Show(e.Message); } }
public async Task <IActionResult> PutCashAccounts(int id, CashAccounts cashAccounts) { if (id != cashAccounts.CashAccountId) { return(BadRequest()); } _context.Entry(cashAccounts).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CashAccountsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }