// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var employee = (from emp in _context.Employee where emp.Id == SalaryPayment.EmployeeId select emp).FirstOrDefault(); //Load the tax table tax record for this employee var taxRecord = (from tax in _context.TaxTable where tax.TaxCode.Equals(employee.TaxCode) select tax).FirstOrDefault(); SalaryPayment.CalculatedTax = employee.SalaryPerAnnum * (taxRecord.TaxPercentage / 100); _context.SalaryPayment.Add(SalaryPayment); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(TaxTable).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaxTableExists(TaxTable.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Employee.Add(Employee); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Company = await _context.Company.FindAsync(id); if (Company != null) { _context.Company.Remove(Company); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } SalaryPayment = await _context.SalaryPayment.FindAsync(id); if (SalaryPayment != null) { _context.SalaryPayment.Remove(SalaryPayment); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } TaxTable = await _context.TaxTable.FindAsync(id); if (TaxTable != null) { _context.TaxTable.Remove(TaxTable); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var employee = (from emp in _context.Employee where emp.Id == SalaryPayment.EmployeeId select emp).FirstOrDefault(); //Load the tax table tax record for this employee var taxRecord = (from tax in _context.TaxTable where tax.TaxCode.Equals(employee.TaxCode) select tax).FirstOrDefault(); SalaryPayment.CalculatedTax = employee.SalaryPerAnnum * (taxRecord.TaxPercentage / 100); _context.Attach(SalaryPayment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SalaryPaymentExists(SalaryPayment.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }