public async Task<ActionResult<PettyCashExpense>> PostPettyCashExpense(PettyCashExpense pettyCashExpense) { _context.PettyCashExpenses.Add(pettyCashExpense); await _context.SaveChangesAsync(); return CreatedAtAction("GetPettyCashExpense", new { id = pettyCashExpense.PettyCashExpenseId }, pettyCashExpense); }
public async Task<IActionResult> PutPettyCashExpense(int id, PettyCashExpense pettyCashExpense) { if (id != pettyCashExpense.PettyCashExpenseId) { return BadRequest(); } _context.Entry(pettyCashExpense).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PettyCashExpenseExists(id)) { return NotFound(); } else { throw; } } return NoContent(); }
public ActionResult DeleteConfirmed(int id) { PettyCashExpense pettyCashExpense = db.CashExpenses.Find(id); db.CashExpenses.Remove(pettyCashExpense); db.SaveChanges(); return(RedirectToAction("Index")); }
public void OnUpdate(AprajitaRetailsContext db, PettyCashExpense payment) { var oldPay = db.PettyCashExpenses.Where(c => c.PettyCashExpenseId == payment.PettyCashExpenseId).Select(d => new { d.Amount, d.ExpDate }).FirstOrDefault(); if (oldPay != null) { CashTrigger.UpDateCashOutHand(db, oldPay.ExpDate, 0 - oldPay.Amount); } CashTrigger.UpDateCashOutHand(db, payment.ExpDate, payment.Amount); }
public ActionResult Edit([Bind(Include = "PettyCashExpenseId,ExpDate,Particulars,Amount,EmployeeId,PaidTo,Remarks")] PettyCashExpense pettyCashExpense) { if (ModelState.IsValid) { Utils.UpDateCashOutHand(db, pettyCashExpense.ExpDate, pettyCashExpense.Amount); db.Entry(pettyCashExpense).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "StaffName", pettyCashExpense.EmployeeId); return(View(pettyCashExpense)); }
public async Task <IActionResult> Create([Bind("PettyCashExpenseId,ExpDate,Particulars,Amount,EmployeeId,PaidTo,Remarks")] PettyCashExpense pettyCashExpense) { if (ModelState.IsValid) { _context.Add(pettyCashExpense); new ExpenseManager().OnInsert(_context, pettyCashExpense); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName", pettyCashExpense.EmployeeId); return(PartialView(pettyCashExpense)); }
// GET: PettyCashExpenses/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PettyCashExpense pettyCashExpense = db.CashExpenses.Find(id); if (pettyCashExpense == null) { return(HttpNotFound()); } return(PartialView(pettyCashExpense)); }
// GET: PettyCashExpenses/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PettyCashExpense pettyCashExpense = db.CashExpenses.Find(id); if (pettyCashExpense == null) { return(HttpNotFound()); } ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "StaffName", pettyCashExpense.EmployeeId); return(View(pettyCashExpense)); }
public void OnDelete(AprajitaRetailsContext db, PettyCashExpense payment) { CashTrigger.UpDateCashOutHand(db, payment.ExpDate, 0 - payment.Amount); }
[Authorize(Roles = "Admin,PowerUser")] public async Task <IActionResult> Edit(int id, [Bind("PettyCashExpenseId,ExpDate,Particulars,Amount,EmployeeId,PaidTo,Remarks")] PettyCashExpense pettyCashExpense) { if (id != pettyCashExpense.PettyCashExpenseId) { return(NotFound()); } if (ModelState.IsValid) { try { new ExpenseManager().OnUpdate(_context, pettyCashExpense); _context.Update(pettyCashExpense); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PettyCashExpenseExists(pettyCashExpense.PettyCashExpenseId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName", pettyCashExpense.EmployeeId); return(PartialView(pettyCashExpense)); }