public async Task <IActionResult> PutStaffAdvanceReceipt(int id, StaffAdvanceReceipt staffAdvanceReceipt) { if (id != staffAdvanceReceipt.StaffAdvanceReceiptId) { return(BadRequest()); } _context.Entry(staffAdvanceReceipt).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StaffAdvanceReceiptExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult DeleteConfirmed(int id) { StaffAdvanceReceipt staffAdvanceReceipt = db.StaffAdvanceReceipts.Find(id); db.StaffAdvanceReceipts.Remove(staffAdvanceReceipt); db.SaveChanges(); return(RedirectToAction("Index")); }
//public void OnUpdate(eStoreDbContext db, StaffAdvancePayment salPayment) //{ // var old = db.StaffAdvancePayments.Where(c => c.StaffAdvancePaymentId == salPayment.StaffAdvancePaymentId).Select(d => new { d.Amount, d.PaymentDate, d.PayMode }).FirstOrDefault(); // if (old != null) // { // UpdateOutAmount(db, old.Amount, old.PayMode, old.PaymentDate, true); // } // UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.PaymentDate, false); // HRMBot.NotifyStaffPayment(db, "", salPayment.EmployeeId, salPayment.Amount, "Advance Payment: " + salPayment.Details); //} public void OnUpdate(eStoreDbContext db, StaffAdvanceReceipt salPayment) { //var old = db.StaffAdvanceReceipts.Where(c => c.StaffAdvanceReceiptId == salPayment.StaffAdvanceReceiptId).Select(d => new { d.Amount, d.ReceiptDate, d.PayMode }).FirstOrDefault(); //if (old != null) //{ // UpdateInAmount(db, old.Amount, old.PayMode, old.ReceiptDate, true); //} //UpdateInAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.ReceiptDate, false); //HRMBot.NotifyStaffPayment(db, "", salPayment.EmployeeId, salPayment.Amount, "Advance Receipt: " + salPayment.Details, true); }
private void ProcessAccounts(StaffAdvanceReceipt objectName) { if (objectName.PayMode == PayModes.Cash) { Utils.UpDateCashInHand(db, objectName.ReceiptDate, objectName.Amount); } //TODO: in future make it more robust if (objectName.PayMode != PayModes.Cash && objectName.PayMode != PayModes.Coupons && objectName.PayMode != PayModes.Points) { Utils.UpDateCashInBank(db, objectName.ReceiptDate, objectName.Amount); } }
public ActionResult Edit([Bind(Include = "StaffAdvanceReceiptId,EmployeeId,ReceiptDate,Amount,PayMode,Details")] StaffAdvanceReceipt staffAdvanceReceipt) { if (ModelState.IsValid) { ProcessAccounts(staffAdvanceReceipt); db.Entry(staffAdvanceReceipt).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "StaffName", staffAdvanceReceipt.EmployeeId); return(View(staffAdvanceReceipt)); }
public async Task <IActionResult> Create([Bind("StaffAdvanceReceiptId,EmployeeId,ReceiptDate,Amount,PayMode,Details")] StaffAdvanceReceipt staffAdvanceReceipt) { if (ModelState.IsValid) { _context.Add(staffAdvanceReceipt); new PayRollManager().OnInsert(_context, staffAdvanceReceipt); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName", staffAdvanceReceipt.EmployeeId); return(PartialView(staffAdvanceReceipt)); }
// GET: StaffAdvanceReceipts/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffAdvanceReceipt staffAdvanceReceipt = db.StaffAdvanceReceipts.Find(id); if (staffAdvanceReceipt == null) { return(HttpNotFound()); } return(PartialView(staffAdvanceReceipt)); }
// GET: StaffAdvanceReceipts/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffAdvanceReceipt staffAdvanceReceipt = db.StaffAdvanceReceipts.Find(id); if (staffAdvanceReceipt == null) { return(HttpNotFound()); } ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "StaffName", staffAdvanceReceipt.EmployeeId); return(View(staffAdvanceReceipt)); }
public async Task <ActionResult <StaffAdvanceReceipt> > PostStaffAdvanceReceipt(StaffAdvanceReceipt staffAdvanceReceipt) { _context.StaffAdvanceReceipts.Add(staffAdvanceReceipt); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStaffAdvanceReceipt", new { id = staffAdvanceReceipt.StaffAdvanceReceiptId }, staffAdvanceReceipt)); }
public void OnDelete(AprajitaRetailsContext db, StaffAdvanceReceipt salPayment) { UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.ReceiptDate, true); }
public void OnInsert(AprajitaRetailsContext db, StaffAdvanceReceipt salPayment) { UpdateInAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.ReceiptDate, false); HRMBot.NotifyStaffPayment(db, "", salPayment.EmployeeId, salPayment.Amount, "Advance Receipt: " + salPayment.Details, true); }
[Authorize(Roles = "Admin,PowerUser")] public async Task <IActionResult> Edit(int id, [Bind("StaffAdvanceReceiptId,EmployeeId,ReceiptDate,Amount,PayMode,Details")] StaffAdvanceReceipt staffAdvanceReceipt) { if (id != staffAdvanceReceipt.StaffAdvanceReceiptId) { return(NotFound()); } if (ModelState.IsValid) { try { new PayRollManager().OnUpdate(_context, staffAdvanceReceipt); _context.Update(staffAdvanceReceipt); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StaffAdvanceReceiptExists(staffAdvanceReceipt.StaffAdvanceReceiptId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName", staffAdvanceReceipt.EmployeeId); return(PartialView(staffAdvanceReceipt)); }
public void OnDelete(eStoreDbContext db, StaffAdvanceReceipt salPayment) { UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.ReceiptDate, true); }