public async Task <IActionResult> PatchEnvelope(int id, Envelope envelope) { if (id != envelope.Id) { return(BadRequest()); } _context.Entry(envelope).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnvelopeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPaidBill(int id, PaidBill paidBill) { if (id != paidBill.Id) { return(BadRequest()); } _context.Entry(paidBill).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaidBillExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAddPaymentMethod(int id, AddPaymentMethod addPaymentMethod) { if (id != addPaymentMethod.Id) { return(BadRequest()); } _context.Entry(addPaymentMethod).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddPaymentMethodExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTransaction(int id, Transaction transaction) { if (id != transaction.Id) { return(BadRequest()); } _context.Entry(transaction).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TransactionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutSalary(Salary salary) { if (SalaryExists()) { var dbSalary = _context.Salaries.First(s => s.ApplicationUser == _userManager.GetUserId(User)); dbSalary.SalaryAmount = salary.SalaryAmount; dbSalary.IsSalary = salary.IsSalary; _context.Entry(dbSalary).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(NoContent()); } catch (DbUpdateConcurrencyException) { throw; } } else { salary.ApplicationUser = _userManager.GetUserId(User); _context.Salaries.Add(salary); await _context.SaveChangesAsync(); return(NoContent()); } }
public async Task <ActionResult <PiggyBank> > PutPiggyBank(int id, TransferInfo info) { //if (id != piggyBank.Id) //{ // return BadRequest(); //} //var pigBank = new PiggyBank() { Id = id, Amount = newAmount }; //_context.Entry(piggyBank).State = EntityState.Modified; var pigBank = _context.PiggyBank.First(a => a.Id == id); double amount = pigBank.Amount; if (info.type == "To") { amount = amount + info.amount; } else if (info.type == "From") { amount = amount - info.amount; } pigBank.Amount = amount; _context.Entry(pigBank).State = EntityState.Modified; try { await _context.SaveChangesAsync(); //_context.PiggyBank.Where(c => c.Id == id).Update() //_context.PiggyBank.Attach(pigBank); //_context.Entry(pigBank).Property(x => x.Amount).IsModified = true; //await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PiggyBankExists(id)) { return(NotFound()); } else { throw; } } return(pigBank); }