public async Task <string> UpdateEmployeeExpense(int id, EmployeeExpense employeeExpense) { try { var res = await _context.EmployeeExpenses.FirstOrDefaultAsync(m => m.ExpenseId == id); res.EmployeeName = employeeExpense.EmployeeName; res.Date = employeeExpense.Date; res.PaymentMethod = employeeExpense.PaymentMethod; res.TransactionNo = employeeExpense.TransactionNo; res.Payee = employeeExpense.Payee; res.Category = employeeExpense.Category; res.Amount = employeeExpense.Amount; res.Currency = employeeExpense.Currency; res.Status = employeeExpense.Status; res.Notes = employeeExpense.Notes; res.Attachment = employeeExpense.Attachment; _context.Update(res); await _context.SaveChangesAsync(); return("Updated Record"); } catch (Exception ex) { throw ex; } }
public async Task <string> UpdateEmployeeExpense(int id, EmployeeExpense employeeExpense) { try { var res = await _repository.UpdateEmployeeExpense(id, employeeExpense); return(res); } catch (Exception ex) { throw ex; } }
public async Task <EmployeeExpense> CreateNewEmployeeExpense(EmployeeExpense employeeExpense) { try { var res = await _repository.CreateNewEmployeeExpense(employeeExpense); return(res); } catch (Exception ex) { throw ex; } }
public async Task <EmployeeExpense> CreateNewEmployeeExpense(EmployeeExpense employeeExpense) { try { _context.EmployeeExpenses.Add(employeeExpense); await _context.SaveChangesAsync(); return(employeeExpense); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> CreateEmployeeExpense(EmployeeExpense employeeExpense) { try { var response = await _service.CreateNewEmployeeExpense(employeeExpense); if (response != null) { return(Ok(response)); } return(StatusCode(StatusCodes.Status204NoContent)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> UpdateEmployeeExpense(int EmployeeExpenseId, EmployeeExpense employeeExpense) { try { var res = await _service.UpdateEmployeeExpense(EmployeeExpenseId, employeeExpense); if (res != null) { return(Ok(res)); } return(StatusCode(StatusCodes.Status204NoContent)); } catch (Exception ex) { throw; } }